DAKAR, Senegal — France announced Monday that it will send hundreds more soldiers to West Africa, and five presidents of countries in the region said they welcome the support in the fight against a surge of Islamist violence.

French President Emmanuel Macron’s pledge to expand his country’s military presence in the restive Sahel, which has endured a crippling wave of attacks in recent months, represented a sharp pivot from his December threat to withdraw troops in light of anti-French protests.

The leaders of Mali, Niger, Chad, Burkina Faso and Mauritania met their French counterpart in southwestern France, where they agreed to build a shared command structure with the European power that once colonized much of West Africa.

Ahead of the announcement, the presidents laid wreaths at a memorial for French soldiers who died this past fall in Mali.

France, which has roughly 4,500 troops in the region — the most of any outside nation by far — plans to deploy another 220 soldiers, Macron said alongside the West African presidents.

In a joint statement, the leaders said they would keep working together to protect civilians and “prevent an extension of the terrorist threat.”

Residents of the Sahel, which lies south of the Sahara, have applauded defense assistance from France in the recent past, but now some blame the foreign troops for deteriorating security.

On Monday, a show of unity emerged from the two-hour meeting in Pau.

“Everybody needs each other, and everybody is paying a heavy sacrifice,” said Paul Melly, a ­Francophone Africa analyst at Chatham House in London.

The summit came just days after the second massacre of soldiers in Niger in as many months, highlighting the grim regularity with which fighters linked to the Islamic State and al-Qaeda strike.

France also suffered a devastating blow in November when two helicopters deployed in the battle against the insurgents collided, killing 13.

Terrorist attacks have increased fivefold in Sahelian countries since 2016, with more than 4,000 deaths recorded and hundreds of thousands of people forced from their homes, according to the latest figures from the United Nations.

The violence is spreading most rapidly in Mali, Burkina Faso and Niger, which endure routine assaults from extremist groups seeking to gain territory, analysts say, and threatens to destabilize a region with one of the youngest populations on Earth.

U.S. officials have warned that Islamist militants are training and plotting attacks from the Sahel, where governments often lack the resources to uproot fighters from remote hideouts in the vast, harsh terrain.

The fight against the Islamic State has moved to this expanse of Africa, Secretary of State Mike Pompeo said in November.

Troops from West Africa, France and the United Nations have struggled to contain the scourge despite pouring millions of dollars and years of manpower into the effort.

France has called on other European nations to send special forces into the fight. German Chancellor Angela Merkel pledged in August to help bolster security in the Sahel.

The United States, which supplies intelligence, training and drone support in the region, is reducing its troop count in Africa by about a tenth over the next few years, according to a 2018 Pentagon announcement. (Most U.S. troops are based in East Africa.)

West Africa’s trouble began when the Libyan government collapsed in 2011 and mercenaries once employed by the deposed leader headed back to their native Mali and teamed up with al-Qaeda fighters — whom the French beat back two years later when the extremists tried to seize the capital, Bamako.

That shared celebration faded after the Islamist militants regrouped and scattered across the Sahel. Fighting is now spilling into Senegal and Ghana, experts say, sparking fears in coastal countries that have not grappled with such threats.

Some in West Africa project anger at the French for not stamping out the problem and wonder aloud if the outside forces have made it worse.

Salif Keita, one of Mali’s most popular singers, urged President Ibrahim Boubacar Keïta in a Facebook video last year to stop “subjecting yourself to little Emmanuel Macron — he’s just a kid.”

Macron hit back at such statements in December, saying he cannot have troops on the ground if Sahelian leaders appear to endorse anti-French sentiments.