When 800 insurgents approached Iraq's second-biggest city on Wednesday, they were able to strike such fear in residents that two divisions of 30,000 Iraqi soldiers fled in panic, dropping their uniforms and weapons. The militants from the Islamic State of Iraq and Syria, or ISIS, roamed the streets of Mosul freely, grabbing weapons from the main army base, freeing hundreds of prisoners from the city's jails and even stealing $480 million from banks. Since then, these fighters have overtaken several other cities in northwestern Iraq, including Saddam Hussein’s hometown of Tikrit.

How could such a small force of fighters overwhelm a trained military force wielding the most sophisticated weapons in the world? Here are some of the reasons:

Many ISIS members are highly trained ex-military: Several former military personnel who served under Saddam Hussein joined the Sunni insurgency after the U.S.-led invasion of Baghdad in 2003.

The military was dissolved, leaving hundreds of thousands of troops suddenly unemployed. The military’s highest-ranking members were reprimanded and barred from working for the new Iraqi government, fueling plenty of discontent.

That’s when “hundreds, if not thousands” of highly-skilled former Hussein officers with tactical knowledge of Iraq’s terrain joined ISIS, according to CNN.

The groups are “unified by the same goal,” a senior Baathist leader told the New York Times. That goal is to rid Iraq of the “sectarian government” and to form a Sunni Region, the leader said.

The Iraqi army is undertrained:  Iraq’s U.S.-funded military, on the other hand, is ill-trained and marred by poor leadership.

The U.S. Department of Defense has invested some $15 billion in training, weapons and equipment to the Iraq government. Soon after Baghdad fell, American generals began to train the new Iraqi military to replace U.S. troops once they left the capital.

But the handover didn’t go as smoothly as U.S. military leaders would have liked. The effort was poorly planned and lacked efficient staffing, the New York Times reported, and that legacy continues today.

The Iraqi government has been “unable to build a healthy state and unable to defend it,” a member of the Iraqi parliament’s defense committee, told the Guardian.

ISIS exploited the Syrian civil war:  How ISIS has been able to accumulate vast resources and build a viable military involved years of strategic planning.

One element of ISIS’s rise involved exploiting the conflict in Syria by gaining control over local resources and leveraging them to tighten its grip in the region, according to the New York Times. In other words, ISIS developed a self-sustaining cash flow.

One example of the way in which ISIS benefited from the ongoing conflict in Syria is that the insurgent group actually sold electricity to the Syrian government from captured power plants.