BAMAKO, Mali — At the heart of the world’s fastest-growing Islamist insurgency, a national force of approximately 12,000 soldiers struggles to defend a population of 20 million.

Malian troops are rapidly losing ground, officials in this West African nation say, as militants linked to al-Qaeda and the Islamic State sweep the rural north and push toward bigger cities.

Leaders pledged this year to nearly double the size of the army, asserting that military help from France and regional partners was not enough to stop the enemy. Yet they are short on weapons, vehicles and basic supplies for combatants already on the payroll — a cost that devours nearly a quarter of Mali’s budget.

“We don’t have a choice,” said Gen. Oumar Dao, chief of staff for the Malian president. “We increase, or they increase.”

Where funding is lacking, enthusiasm surges: An average of three people raise their hands for every opening in the army, according to official estimates, even as the war against the extremists reaches bloody new heights.

Dozens of Malian soldiers have died since January, and civilian casualties have climbed every year since 2016 as the unrest spilled over the border to Burkina Faso and Niger.

France, which has 4,500 troops in West Africa, the most of any foreign ally, has urged other European powers to send backup, while the United States weighs drawing down in the region. (The Pentagon could shift resources east to counter China and Russia, officials have said.)

Mali and its allies are up against a coalition of al-Qaeda loyalists, known by its acronym JNIM, that has as many as 2,000 fighters in the region, as well as the Islamic State in the Greater Sahara, which is thought to be hundreds strong.

Danielle Paquette/The Washington Post

The groups are on a mission to grab territory, officials say, so they can train, gather strength and launch attacks on targets worldwide. The militants, at war with one another in the Middle East, are known to be coordinating efforts in West Africa, ordering villagers to join or die — or swaying them with stacks of cash.

“They want to convert, radicalize and control people,” said Gen. Ibrahim Fane, secretary general of Mali’s Ministry of Defense.

The military, he said, aims to enroll those at risk of getting swept into extremism: young, unemployed, hungry for purpose.

Many rural Malians feel abandoned and suspicious of authority, however. Remote villages tend to lack electricity, schools, hospitals — even sources of clean water.

Local militias have grown where the government is absent, fueling violence between ethnic groups that researchers say claimed hundreds of civilian lives last year.

Residents have accused Malian soldiers, meanwhile, of hurting and killing innocent people suspected of working with the militants, according to reports from Human Rights Watch. Leaders say reforms are underway, but they lack the money to fix every problem at once.

“It is not enough to simply hire soldiers,” said Marc-André Boisvert, a Mali analyst in Washington focused on the army. “Trust needs to be built.”

Danielle Paquette/The Washington Post

In Bamako, the capital, life continues in relative calm. Terrorist attacks over the years have rattled people, but the dearth of jobs seems more pressing, several city dwellers said.

Careers in the military are highly sought after — “like when you have a beautiful daughter and all these boys circle the house,” said Col. Maj. Diarran Kone, the army’s spokesman. “We cannot possibly take everyone who is coming forward.”

Interest in enlisting tends to fluctuate with the health of the economy in Mali, analysts say, as it does in the United States. Being in the military here is viewed as a source of steady income with a side of prestige. (The army declined to disclose its pay data.)

Mali aims to add and train at least 10,000 soldiers in coming months, Kone said. Successful applicants, he added, are physically tough with clean criminal records.

Securing a spot is “extremely” difficult, said Issa Fane, 25, who tried unsuccessfully two years ago. Now he’s studying history and hoping a college degree could boost his chances.

“I either die in the army, or I die some other way,” he said. “Fighting for my country is my dream.”

Kalifa Mounkoro, 32, a mechanic with a penchant for Superman shirts, is trying a different path: He’s saving up about $500 to buy a gun.

People who belong to militias in the countryside can exchange their weapons for a Malian army uniform, he has heard, as part of the nation’s disarmament program.

“I can make more money,” he said, “and protect the future for my children.”

Eyeing a similar opportunity, Siga Camara, 31, joined a self-defense group that operates mostly in the north.

Her primary role is guarding a Bamako guesthouse for leaders in town for meetings. She volunteers for eight-hour shifts, sitting outside the wooden double doors at night with an AK-47, stashing away tips to buy a firearm of her own.

“It’s stability,” said the woman in camouflage, “and stability makes people respect you.”

Mamadou Tapily contributed to this report.