DIABALY, Mali -- At first, the battle went well.
Boubacar Yattara, a 25-year-old Malian soldier, fed the heavy machine gun atop an armored vehicle. His unit fired on a truck full of Islamist militants, destroying it. He radioed for reinforcements, but his commanding officer had bad news. His fellow soldiers had already fallen back, beating a hasty retreat.
So Mr. Yattara did what other soldiers had done as the fighting intensified: He stripped off his uniform, waded through an irrigation canal and melted into the town's civilian population.
"They abandoned us," Mr. Yattara said of the other soldiers, speaking from the hospital bed where he was being treated for a concussion. "We barely escaped with our lives."
In many ways, the battle for Diabaly was over before it even began, the latest in a long string of humiliating defeats for an army that the United States once hoped would be a model for fighting Islamic extremism in one of the most forbidding regions of the world. Instead, it is a weak, dysfunctional force that is as much a cause of Mali's crisis as a potential part of the solution.
Beyond fleeing in the heat of battle, hundreds of Malian soldiers, including commanders of elite units trained by the United States, defected to the rebels who swept across the desert last year, according to senior Malian military officials. Then an American-trained captain toppled the democratically elected government in a coup, creating a chaos that allowed half the country to fall into the hands of Islamist militants.
Now that same Malian Army, which the United Nations expected to be rebuilt over many months of training, has been thrust into the fight once again after a sudden militant surge this month -- though it is no better prepared than it was before. Indeed, diplomats in the capital, Bamako, and at the United Nations say that if French warplanes and troops had not joined the effort, the Islamist fighters would have overrun the entire country.
"We thought the army would protect us," said Gaoussou Keita, a 57-year-old radio repairman in Diabaly, who spent nearly a week hiding from militants who occupied his hometown this month. "But they simply ran away."
Worse than that, human rights groups say, Malian soldiers have been accused of atrocities in recent weeks, including summary executions of at least 11 people suspected of being insurgents.
"These acts of reprisal combined with the extreme tension between communities constitute an explosive cocktail that makes one fear the worst," said Souhayr Belhassen, the president of the International Federation for Human Rights, in a statement.
The army has abused its own soldiers as well, a reflection of the bitter divisions that have often kept the army more focused on its critics and internal rivals than on the militants controlling the nation's north. According to Human Rights Watch, defiant soldiers have been beaten and forced at gunpoint to perform anal sex on one another.
Instilling a respect for human rights and international law was supposed to be a cornerstone of the training for Malian forces, according to the United Nations Security Council resolution that passed in December. Suddenly, the unexpected Islamist advance and the French intervention inverted those tortuously negotiated plans -- forcing some Malian units to fight right away while others wait for training later.
But the army's frequent defeats and spotty human rights record have rekindled longstanding doubts about whether it can -- or perhaps even should -- be left to hold on to the gains French troops have made.
"Given that the Malian Army is internally divided, lacks the capacity to effectively project force, has been implicated in human rights abuses, and is very small," said a report by the Congressional Research Service this month, "it is uncertain whether Malian forces will be able to effectively follow up on French military strikes by securing and holding territory."
So far 1,600 troops from Nigeria, Togo, Niger and Benin have arrived in Mali to form part of an African-led force to drive back the militants and ultimately recapture the northern half of the country. But many more are expected, and it will take months to begin retooling Mali's ragtag army to the point that it can play any major role in the fight to chase militants from the north, analysts say.
In the meantime, many Malians, who have watched their government and country be thrown into turmoil since the army coup last year, have grown frustrated at the military's failure to stop the militant threat.
"Without the help of the French," said Diabaly's mayor, Oumar Diakite, the Islamists fighters "would still be here. They would have gone all the way to Bamako."
Mr. Yattara's account of the battle for Diabaly helps illustrate some of the myriad troubles plaguing Mali's army. Assigned with reloading the heavy machine gun atop an armored vehicle based in this central Malian town, Mr. Yattara had long complained to the chief of matériel that his weapon was unfit for service.
"It was wobbling on the top of the vehicle and not firing effectively," Mr. Yattara said. "But they ignored me. I fixed it as much as I could with some stones to weigh down the gun."
On the day the Islamists arrived, Mr. Yattara's vehicle was sent to a forward position, placed between two others in a string of defenders designed to protect Diabaly.
The weapon on the first vehicle failed, so the soldiers fled, Mr. Yattara said. They begged for reinforcements, but the rest of the soldiers had already retreated. Eventually he ran out of ammunition, too, and decided he had to flee as well, suffering the concussion when a bullet hit his helmet.
"Our commanders don't listen to us, they don't support us," Mr. Yattara said bitterly. "It is complete chaos."
For years, the United States worked closely with Mali's military as part of a more than $500 million counterterrorism program to train and equip armies across the Sahara to combat militants. With only about 7,000 people in its military and other security forces, and just a handful of working helicopters and airplanes, Mali had acknowledged how daunting a task it was to defend its vast desert borders and drive out growing numbers of Islamist militants, including those aligned with Al Qaeda in the Islamic Maghreb.
So the Malians eagerly agreed five years ago to join a multiyear partnership between the State and Defense Departments that also included Algeria, Burkina Faso, Chad, Mauritania, Morocco, Niger, Nigeria, Senegal and Tunisia. It was the most ambitious American counterterrorism effort ever in the region.
American Special Forces provided Malian infantry troops with training in marksmanship, border patrol, ambush drills and other skills. The program also offered Malian forces their first opportunity to train with more capable armies from neighbors like Senegal, a trend toward regional cooperation that budget-conscious American policy makers and military officials sought to promote.
But no one seemed to anticipate the sudden influx of heavily armed, battle-hardened fighters returning from Libya after the fall of Col. Muammar el-Qaddafi. They reinvigorated a longstanding rebellion in the north, spurring as many as 1,600 Malian soldiers to defect, according to one senior Malian military official.
The remaining Malian forces were routed so thoroughly that troops overthrew the government in Bamako in frustration. As a result of the coup, the American military suspended aid and training to the Malian military.
Pentagon officials acknowledged that the training and equipping of the Malian forces failed to keep pace with the growing threat from increasingly powerful Islamist extremists.
"We provided training and equipment for many years now, but in relatively modest quantities," Amanda Dory, a deputy assistant secretary of defense for Africa, told a Senate hearing last month. "I don't think that level of resourcing was commensurate with the threat."
Indeed, Malian commanders say that they simply do not have the equipment or training to face the Islamist militants in battle.
"We are a poor country," said Col. Seydou Sogoba, leader of the troops in Diabaly. "No African country can face this kind of threat alone. This is an international war that is being fought in Mali. We have done what we can. Now others need to come and help us."
Eric Schmitt contributed reporting from Washington, Neil MacFarqhuar from the United Nations, and Scott Sayare from Paris.
This article originally appeared in The New York Times.