LOME, Togo — West African leaders are urging the United States to stay in the fight against extremist groups that are rooting deeper into the region as the Pentagon weighs a significant troop pullout from the continent.

Parts of the Sahel, a dry stretch of land south of the Sahara Desert, have fallen to militants linked to the Islamic State and al-Qaeda who are offering shelter to fighters fleeing the Middle East, the presidents of Senegal and Togo told The Washington Post in separate interviews.

“If one actor leaves the chain, it weakens the whole group,” Togolese President Faure Gnassingbé said.

The heads of state, whose nations border a worsening conflict, said the international community must unite against the attackers. Both expressed concern that terrorism is on the brink of spilling into their countries, which have not previously grappled with such a threat.

Withdrawing U.S. troops as Islamist violence surges would be a “mistake,” Senegalese President Macky Sall said in his first public comments on the matter.

“It would be a mistake, and it would be very misunderstood by Africans,” he said, “because instead of coming to help, you wish to remove the little help there is.”

Gnassingbé, Togo’s leader of 15 years, said militants from Iraq and Syria are slipping into the region through restive Libya, where they aim to radicalize locals and build an army.

“Those terrorists will be stronger here,” Gnassingbé said, so the United States should “fight on both ends — in the Middle East and in Africa.”

The Pentagon is considering a force drawdown in Africa to accommodate a shift in defense priorities to the Asia-Pacific region.

Some 6,000 U.S. troops are based on the continent. About a quarter are stationed in West Africa, mostly in Niger, where they provide training, drone support and intelligence.

French President Emmanuel Macron has called the help “irreplaceable.”

Roughly 4,500 French troops partner with U.S. forces, regional soldiers and U.N. peacekeepers in West Africa.

President Trump has tweeted that he wants to remove American soldiers from “ridiculous Endless Wars” across the world. Administration officials say the United States should focus on countering Chinese and Russian influence in Africa.

Authorities and residents in the Sahel are worried that the world is reacting too slowly to a crisis that is killing thousands, displacing millions and threatening to trigger global consequences.

“ISIS and al-Qaeda affiliates that have attacked us in the United States in the past are expanding their reach in the region,” said Andrew Young, the U.S. ambassador to Burkina Faso. ISIS is another name for the Islamic State.

Terrorist attacks in rural Mali, Niger and Burkina Faso have climbed fivefold since 2016, according to the Africa Center for Strategic Studies in Washington.

Assailants are chasing people off their ancestral land and rapidly gaining territory to plot attacks on targets worldwide, Western officials say. They have massacred troops at army bases and stolen sophisticated equipment.

International aid workers who deliver food and medical supplies to victims in these conflict zones say the areas where they can safely travel shrink with each passing month, leaving people to fend for themselves in villages that the government can no longer reach.

West African leaders have pledged to spend $1 billion over the next five years to fight extremism, but governments in the Sahel are struggling against more basic problems, such as a lack of drinking water.

Over the past month, suspected terrorists have attacked a humanitarian outpost in Nigeria’s northeastern Borno state, killing 27, and an army base in western Niger, killing 89.

Fourteen people, mostly children, died in northern Burkina Faso when their bus hit a roadside bomb, and 18 soldiers were wounded in neighboring Mali after assailants struck a United Nations base.

As the violence creeps closer to West Africa’s coastal states, leaders are focused on securing borders and sharing intelligence with their regional counterparts.

The presidents of Senegal and Togo met in the Togolese capital of Lome over the weekend at a conference on fake medicine.

Gnassingbé, the Togolese leader, said “thousands” of fighters from the Middle East have reached West Africa since the collapse of the Islamic State in Syria.

He disputed Trump’s claim that the terrorist group has been “100 percent” defeated.

“Look at the recent attacks,” Gnassingbé said. “More professional, more powerful, and the consequences are devastating.”

There is little data on foreign militants operating in West Africa, but two senior U.S. officials in the region say fighters from Syria and Iraq have turned up in Nigeria and Mali. They spoke on the condition of anonymity because they were not authorized to speak to the media on the matter.

Islamic State and al-Qaeda affiliates that once clashed now appear to be trading advice on building explosives, collecting taxes and recruiting people, and allowing one another safe passage through areas they control, the officials said.

Many militants are homegrown, security analysts say. They are a diverse, complex mix of radical ideologues, men who were captured as children, bandits exploiting chaos and people with nowhere else to turn.

Terrorists are building networks from “Libya to Niger” and beyond as they strive to take over an expansive region, said Sall, the Senegalese president.

“So,” he said, “it takes a collective effort — America, Europe, Africa — to oust terrorism.”