The Iraqi army’s collapse this week marked a stark failure for the U.S. military that trained it and for Prime Minister Nouri al-Maliki’s government, which has struggled to address leadership and morale problems that now threaten the force’s ability to defend the country.

Although they far outnumbered the insurgents and had greater firepower, Maliki’s troops have fled by the thousands in the country's north, allowing the Islamic State of Iraq and Syria (ISIS) to take the city of Mosul and start an ominous march toward Baghdad.

Former U.S. military officials who oversaw the building of the Iraqi military placed much of the blame for that dereliction on Maliki, who has purged the Iraqi army of some of its most capable leaders.

The army’s dilemma came down to a single question that soldiers had to ask themselves as they faced sudden attack, said Derek Harvey, a former top U.S. military official in Iraq: “Do I want to die for Maliki?”

Instead of focusing on training and equipping the military, Maliki has “used all of his tools to target his political rivals,” said Emma Sky, a top adviser to U.S. generals in Iraq during the latter years of the U.S. occupation. “Maliki sought to consolidate power and protect his regime. His opponents fear and distrust him.”

The Islamic State of Iraq and Syria (ISIS), an al-Qaeda splinter group that has seized a huge chunk of northern Iraq, is led by Abu Bakr al-Baghdadi, a relatively unknown and enigmatic figure. (The Washington Post)

In particular, Maliki, a Shiite Muslim, has alienated Sunni tribal leaders in northern and western Iraq who helped shift the course of the war in 2007 when they turned on forces aligned with al-Qaeda in Iraq and backed the U.S. military.

Some former U.S. military officials also pointed to the failure of the United States and Iraq to secure an agreement that would have permitted American troops to remain in Iraq after 2011 — a pact that would have allowed for more training.

But the larger problem, many say, is Maliki, whose centralization of decision-making has made it hard for the Iraqi military to react quickly to changes on the battlefield.

In many instances, generals must wait for phone calls from the prime minister’s office before they can move troops, said retired Lt. Gen. James M. Dubik, who led the U.S. military’s training effort from 2007 to 2009. Dubik said the Iraqis haven’t even been able to select officers to send for training in the United States paid for by the Pentagon.

“The prime minister’s office can’t decide who to send,” Dubik said. “So the courses go unfilled.”

The sudden collapse of Iraqi forces also highlights gaps in the army that U.S. military officials knew existed when American forces withdrew at the end of 2011. U.S. commanders had hoped to keep as many as 10,000 troops in the country to help Iraqi forces with planning large-scale operations of the kind needed to launch a counteroffensive on a major city such as Mosul or Fallujah.

U.S. officials also realized that they needed to continue to work with the Iraqis to build logistics systems to ensure that armored vehicles and helicopters are ready for war.

The Obama administration, nevertheless, decided to withdraw U.S. forces following the Iraqi government’s refusal to grant American troops immunity from prosecution beyond 2011.

Rick Brennan, a former top military adviser in Iraq, said the Iraqi military still lacks basic capabilities in areas such as communications, logistics and maintenance. He said it also lacks any significant air power, although Iraq is buying U.S. F-16 fighter jets and Apache attack helicopters.

“Over time, what’s occurred is that the Iraqi army has no ability to defend itself with close air support once it starts to get overrun,” Brennan said. “At the small-unit level, once they start getting hit, they are abandoning post, both Sunni and Shia, on a scale we never anticipated.

“What’s a surprise is how rapidly it’s been occurring and the degree to which you see total collapse of large elements of Iraqi forces, leaving behind probably hundreds of millions of dollars of equipment” in the hands of ISIS, Brennan said.

“It’s hugely frustrating,” said Michael D. Barbero, a retired U.S. Army lieutenant general who oversaw the training of Iraqi troops from 2009 to 2011. “It’s a fault of both Washington and Baghdad. We knew they had chinks in their armor, and we knew they weren’t going to get better once we left. And yet we didn’t try hard enough to get an agreement to keep some people there.”

Barbero said that despite years of training and billions of dollars in U.S. time and equipment, Iraq’s military is still a “checkpoint Army,” more interested in manning roadblocks than developing intelligence and engaging in counterinsurgency missions.

He said U.S. trainers had stressed that intelligence-gathering was the key to disrupting insurgent networks active in Iraq. U.S. officials set up high-tech command and control centers, but Iraqi military leaders largely coordinate their operations by cellphone, he said.

“Our Army continuously trains; that wasn’t in their DNA,” Barbero said. “We set up all these training bases. We built ranges and encouraged them to do live fire. And it just didn’t take, for whatever reason. I’m not saying we’re stainless in this. Obviously we could have done some things better.”

Barbero said he was in Iraq a month ago, and Iraqi military officials assured him that the ISIS threat was contained. “I know no Iraqis saw this coming,” he said.

The Americans also never anticipated that the Iraqis would face an enemy force as well-trained as ISIS. Throughout the U.S. occupation, the insurgents, fearful of U.S. air power, rarely attacked with a force larger than 100 to 200 men. Most attacks were launched by small teams of five to 15 fighters.

What’s not yet clear is whether the damage to Iraq’s army is limited to the units in the northern third of the country or whether it will extend to forces in Baghdad, causing the entire force to fracture.

The units in Mosul had been fighting a low-grade insurgency for months. Those units also included a high percentage of Sunnis, who are less loyal to the Shiite-led government. It’s possible that the units in Baghdad will be more willing to fight.

“This could be as catastrophic as it looks, or it could be less,” said Douglas Ollivant, a retired U.S. Army colonel who still does business in Iraq. “There’s no question it is bad. But we won’t know for sure until we see how units from the south perform.”

Other former military officials were less sanguine. “Once a fighting force in one area folds, it can become an epidemic very quickly,” Dubik said.

The one positive aspect for the United States is that Maliki may now be willing to cooperate with former Sunni leaders in exchange for U.S. help.

“He knows he’s facing an existential threat,” Dubik said. “He has to realize that both his political life and his physical life are at risk.”

In recent months, as ISIS started taking more and more territory, Iraqi military officials have made increasingly more urgent requests for U.S. military help, including drone strikes.

“You’d sit down with a general, and they literally thought we could make this go away with a push of a button. They had no grasp on reality,” said a U.S. defense official who spoke on the condition of anonymity to describe discussions with the Iraqis.

Harvey, a former top intelligence adviser to David H. Petraeus, who served as commander of the allied forces in Iraq, said the military’s problems are a symptom of a much deeper crisis in Iraqi society created largely by Maliki’s mishandling of delicate sectarian tensions.

“The core of all this is political,” Harvey said. “What we’re facing today is not al-Qaeda, and Prime Minister Maliki wants us to focus on ISIS as the primary threat. The vanguard is ISIS. The breadth and depth of this is basic Sunni Arabs who are fed up.”

Karen DeYoung contributed to this report.