When Obama took office he inherited a pacified Iraq, where the terrorists had been defeated both militarily and ideologically.
Militarily, thanks to Bush’s surge, coupled with the Sunni Awakening, al-Qaeda in Iraq (AQI, now the Islamic State of Iraq and Syria, or ISIS) was driven from the strongholds it had established in Anbar and other Iraqi provinces. It controlled no major territory, and its top leader — Abu Musab al-Zarqawi — had been killed by U.S. Special Operations forces.
Ideologically, the terrorists had suffered a popular rejection. Iraq was supposed to be a place where al-Qaeda rallied the Sunni masses to drive America out, but instead, the Sunnis joined with Americans to drive al-Qaeda out — a massive ideological defeat.
Obama took that inheritance and squandered it, with two catastrophic mistakes:
First, he withdrew all U.S. forces from Iraq — allowing the defeated terrorists to regroup and reconstitute themselves.
Second, he failed to support the moderate, pro-Western opposition in neighboring Syria — creating room for ISIS to fill the security vacuum.