Camp Lemonnier, home to some 4,000 US soldiers and contractors, is vital to US military operations in Somalia against militant groups like Al-Shabaab.
Camp Lemonnier, home to some 4,000 US soldiers and contractors, is vital to US military operations in Somalia against militant groups like Al-Shabaab, and also provides support for US operations in Yemen, where special forces regularly carry out drone strikes against Al-Qaeda in the Arabian Peninsula.
China is also in the process of establishing its first overseas military base in the small port country just a few miles from the US camp, which has raised concern in Washington.
"I have no doubt that the French will continue to make their own decisions in their own best interest and that the terrorists will not enjoy these decisions" after the (French presidential) election, Mattis told reporters.
"They have always proven that they will stand up when it is time to stand against something like this."
The US backs France's Operation Barkhane, under which its military is fighting Islamists in five countries across the Sahel region -- Mauritania, Mali, Chad, Niger and Burkina Faso -- alongside African allies.
During the visit to the former French colony Mattis met with President Ismael Omar Guelleh as well as with General Thomas Waldhauser, commander of US troops in Africa.
"For (the defence department) Camp Lemonnier and Chabelley are critical in terms of logistics. They support multiple US combat command", a senior defence official said, referring to an airfield close to the camp, from which the US military operates drones.
Another senior defence official, also speaking on condition of anonymity, played down any concerns about China's base construction.
"At this point I don't see why we should not be able to comfortably coexist with the Chinese presence, the way we do with the Japanese, the French..." the official told reporters last week.
Critics say China is trying to construct a so-called "pearl necklace" in the Indian Ocean -- a reference to various ports in which China has direct interest in operations including Gwadar in Pakistan and the Colombo Port City in Sri Lanka.
However, Waldhauser assured the US Senate's armed forces committee in March that he had spoken to Guelleh "and expressed our concerns about some of the things that are important to us about what the Chinese may or may not do".
With a population of 875,000 people, Djibouti lies on the Bab el-Mandeb Strait, a gateway to the Suez Canal, one of the world's busiest shipping routes.
It has launched major infrastructure projects aimed at turning it into a regional hub for trade and services, using money largely borrowed from China.
In October, Ethiopia formally inaugurated a train line from Addis Ababa to Djibouti, a Chinese-funded project that is Africa's first fully electrified transnational railway.
China has said it wants the base to support its UN peacekeepers in Africa, allow it to evacuate its nationals in a crisis, and to support its anti-piracy activities off Somalia.
Piracy had waned in recent years, but Waldhauser said it had reemerged in the past month, with half a dozen pirate attacks recorded.
The United States set up base in Djibouti shortly after the September 11, 2001 attacks to back up operations against Al-Qaeda and the Taliban in Afghanistan and was described as a temporary measure at the time.
But this was formalised and buttressed in 2014 when the US signed an agreement for 20 years.
France has about 1,450 troops stationed in Djibouti.