Ultimately, at great political risk, President Obama approved negotiations with the Iraqi government to allow a force of around 5,000 American troops to stay in Iraq to provide counterterrorism support and air cover and to train the Iraqi army. But, as commander in chief, he was unwilling to strand U.S. forces in a hostile, anti-American environment without the legal protections and immunities required to ensure soldiers didn’t end up in Iraqi jails. These protections, which are common in nearly every country where U.S. forces operate, were guaranteed under the 2008 status of forces agreement negotiated by the Bush administration; Obama simply demanded that they continue under any follow-on accord.
Iraq’s prime minister, Nuri al-Maliki, told U.S. negotiators that he was willing to sign an executive memorandum of understanding that included these legal protections. But for any agreement to be binding under the Iraqi constitution, it had to be approved by the Iraqi parliament. This was the judgment of every senior administration lawyer and Maliki’s own legal adviser, and no senior U.S. military commander made the case that we should leave forces behind without these protections. Even Sen. John McCain, perhaps the administration’s harshest Iraq critic, admitted in a December 2011 speech discussing the withdrawal that the president’s demand for binding legal immunities “was a matter of vital importance.” Moreover, because the 2008 security agreement had been approved by the Iraqi parliament, it seemed both unrealistic and politically unsustainable to apply a lower standard this time around.
Unfortunately, Iraqi domestic politics made it impossible to reach a deal.That's the inside story, but it's never been a secret.