So, nothing to do with all of the US troops and bases occupying their territory?
Boy, people have short memories. Iraq didn't renew a security agreement back in 2011 for political reasons. The local population didn't want it. The US was mostly withdrawn from Iraq at the end of December 2011. It took about 6 months before ISIS took advantage of the situation.
From 2nd link-
In July 2012, al-Baghdadi released an audio statement online announcing that the group was returning to former strongholds from which US troops and the Sons of Iraq had driven them in 2007 and 2008. He declared the start of a new offensive in Iraq called Breaking the Walls, aimed at freeing members of the group held in Iraqi prisons. Violence in Iraq had begun to escalate in June 2012, primarily with AQI's car bomb attacks, and by July 2013, monthly fatalities exceeded 1,000 for the first time since April 2008.
I'm too lazy to look up when the US sent sizable forces back to Iraq, but it was only on request and permission of the Iraqi government.