Military officials and independent analysts stressed that American and other Western military aid may at best buy time for African allies to address poverty, lack of education, government corruption and other grievances that extremist groups seek to exploit. But there is little confidence that these daunting, endemic problems will be resolved soon. That leaves the United States and its European allies to keep the threat from spreading.

The State Department has in the past two years provided $323 million in training and other security assistance to the so-called G5 Sahel countries — Burkina Faso, Mali, Niger, Chad and Mauritania. But the G5 force, ultimately set to grow to 5,000 troops, has been slow to halt the militants’ advance.

Small U.S. assistance is crucial to a larger French mission.

The American military has a relatively light footprint across Africa, relying on European and African partners to carry out most counterterrorism missions from the Sahel to Somalia, with the Pentagon providing air power when needed. About 5,200 U.S. troops and 1,000 Defense Department civilians or contractors work throughout Africa, mainly training and conducting exercises with local forces. About 1,400 of those troops are in West Africa, a force that could shrink to 300 under one of Mr. Esper’s options.

“We can have a large effect with a very small force,” Brig. Gen. Dagvin R.M. Anderson, the top American Special Operations officer in Africa, said in an interview in Nouakchott on the sideline of the counterterrorism exercise.

European allies — and President Trump’s own advisers — have advocated continuing these American security measures on the continent, arguing that this relatively small investment has an outsize effect in helping keep terrorists and global competitors at bay.

In a phone call last week, President Emmanuel Macron of France urged Mr. Trump to keep providing American assistance — intelligence, aerial refueling and logistics at a cost of about $45 million a year, barely a rounding error in the Pentagon’s nearly $800 billion annual budget — until France fills its counterterrorism gaps.

To show its resolve and stave off deep immediate American cuts, France, the former colonial power in West Africa, is rushing 600 additional troops to the region, for a total of 5,100. It also says 400 more Special Operations forces from other European nations will arrive by late summer.