The math seems so simple. The Iraqi army has 250,000 troops; its enemies, the Islamic State of Iraq and the Levant (ISIS), somewhere around 7,000. The Iraqi army has tanks, planes, and American training. ISIS has never fielded a tank or a plane and its troops didn't get formal training from an advanced military. Yet ISIS is demolishing the Iraqi army on the battlefield, seizing a massive swath of the country's northwest. Why?

It comes down to two things: training and professionalism. ISIS learned how to fight, while the Iraqi army has long been a weak fighting force. All the weapons in the world won't matter if you don't know how to wield them. And ISIS's victories, not to mention the Iraqi army's repeated failures, tell you a lot about the country's larger crisis.

The Iraqi army has never been disciplined

In Mosul, Iraq's second most populous city, about 800 ISIS fighters invaded and sent 30,000 Iraqi army troops running. That's been portrayed as a sudden collapse of the Iraqi army, but that's not quite right. "The Iraqi army has been collapsing for months now," Yasser Abbas told me.

Abbas, originally from Baghdad, is an analyst at the private research and consulting firm Caerus Associates. Before that, he served as a linguist in for the military in Iraq from 2005 to 2009. "At the end of 2006, I was involved in training the Iraqi national police in Baghdad," he said. "The amount of corruption and under-training was [astounding] ... insubordination became widespread."

So, for Abbas, the military's collapse "didn't happen at once. It's been happening for a very long time." For instance, the governor of Mosul ordered the military units in the area to go to a particular town, and "the battalion commander said no, it was too dangerous." It's the same insubordination problem the army has had for years.

And even when they do fight, many units aren't all that effective. "They'll stand up with a PKM [machine gun] and blast off 250 rounds" says Phillip Smyth, a researcher at the University of Maryland. "What is that doing?"

This isn't true of all Iraqi units, some of which, particularly around Baghdad, are quite well-trained. But many of the ones in the northern, Sunni-held regions of Iraq where ISIS made such large gains were some of the worst.

insubordination became widespread

How did the Iraqi army get this bad? One explanation is sectarianism: the Iraqi government is dominated by Shia Muslims, whereas ISIS and its allies are Sunnis. Perhaps Sunni soldiers in the mostly-Sunni northwest simply ran because they didn't want to fight for a Shia government.

There's some truth to this theory, but "it's been overblown," according to Abbas. Two other things stand out. First, Iraqi Prime Minister Nuri al-Maliki significantly weakened the army. He replaced effective Sunni officers with Shia ones and well-trained generals with loyalists. As Slate's Joshua Keating explains quite well, this was an attempt to protect his own political position. A strong, independent army could launch a coup d'etat. An army filled with your cronies is safer.

But, as the decade-long history of Iraqi army failures suggest, it's not just about Maliki. Rather, it's that the modern Iraqi army simply has never been a particularly strong institution. From the Iran-Iraq War of the 1980s to the Gulf War to the 2003 American-led invasion, Iraqi units have performed pretty poorly. When the US military tried to rebuild the Iraqi army essentially from scratch after disbanding it in 2003, it just didn't have a lot of raw material to work with.

ISIS advantages: training and experience

ISIS wasn't always strong enough to take real advantage of the Iraqi military's intrinsic weakness. "When the US fought ISIS in 2007, they were very weak," Abbas explained. "North of Baghdad, it took less than 24 hours for the whole organization to collapse in the face of a few soldiers and tribal militias."

But between 2007 and now, something changed. "When you like at the [ISIS] training videos from the mid 2000s, and compare them to ones from 2010, they're moving from terrorist tactics like how do you create an IED to things that include operations, strategy tactics," Nathaniel Rosenblatt, the head of Caerus' Middle East division, says.

Rosenblatt and Abbas say there's been an influx of skilled Saddam-era military leaders and soldiers into ISIS' ranks. "When you look at some of the reports about the leadership under [ISIS commander Abu Bakr] al-Baghdadi," Rosenblatt said, "those second-in-command guys have very strong ties to Saddam's army." Acquiring lots of weapons, money, and experience over the course of the Syrian war allowed them to translate that new training into real military effectiveness.

It's hard to overstate how much of advantage this training and professionalism gives the Islamist group. "ISIS knows how to use smaller units" effectively against larger forces, says Smyth. They're "very efficient, and you have to deal with that."

This matters greatly. An undisciplined force, one whose movements aren't well coordinated or can't deploy proper tactics for taking city blocks, can be beaten by a much smaller opponent that knows what it's doing.

This puts the conflict into a weird sort of violent stasis

Superior training and motivation can also give defenders an extra edge. Smyth points to the World War II Battle of Wake Island as an example, where US troops held off a much larger Japanese force by digging in and creatively using their environment and dwindling resources. The Iraqi army has had a similarly tough time making progress in ISIS-held territory.

This leaves the conflict locked in a violent stasis. The Iraqi army will press ISIS-held territory, and possibly push them back on the margins, but it isn't strong enough to roll back ISIS all the way. "Bottom line: I think ISIS will be able to hold Mosul for some time," Rosenblatt says. "Unless Maliki is really pushed, I don't think he's going to be able to march all the way to Mosul with a Shia force. The political aspects are too sensitive."

Meanwhile, ISIS doesn't have the strength to challenge the more effective Iraqi army units defending Baghdad and the other largely Shia areas. "Technically, they do [want to take Baghdad]," Smyth says. "But I don't think they're stupid. They won't jump into the open jaws of the crocodile."

Three things could transform the conflict

There are three critical factors that could break this bloody status quo.

First, a collapse in ISIS' popular support. ISIS has a long history of brutal treatment of civilians, and every analyst I spoke to agreed that a loss in Sunni civilian support would be a back-breaker for ISIS. "Insurgencies can make do with passive support from the bulk of the population, but if an ideology is too radical, it risks sparking a backlash," said Jason Lyall, an expert on counterinsurgency at Yale University. "Given the size of the outflow of people from Mosul, it is apparent that ISIS' ideology may find little support among the civilian populace."

Second, either side's allies could alter the military balance dramatically. ISIS fights with a broad range of Islamist, tribal, and Saddam-loyalist groups; if those groups turn on ISIS, which they very well might, it could break the group's hold on the territory.

On the flip side, the Iraqi army is backed by Iran and several Shia militias. It's also recruited thousands of Shia volunteers — about 200,000, by All Iraq News Agency's count — for impromptu anti-ISIS militias. According to Abbas, this "massive Shia recruitment" could potentially shift the balance of power dramatically.

it's far, far too early to count ISIS out

Third, an unexpected military intervention by a third party. The semi-autonomous Kurdish area in northwest Iraq is adjacent to ISIS' stronghold. Their powerful military, which has already had small clashes with ISIS-aligned forces, could challenge ISIS. And who knows what effect large-scale a American air campaign against ISIS would have on the balance of power.

You may have noticed that all three of these scenarios trend badly for ISIS. That's true, and it's because ISIS has put itself in a precarious political position. It doesn't have any real reliable friends, and it's challenging a government that represents the Iraqi religious majority that also has backing from the United States and Iran.

But it's far, far too early to count ISIS out on the basis of hypothetical scenarios. Their military record in Iraq proves that they can outperform expectations.