Iraqi premier Nuri al-Maliki's mishandling of security and perceived sidelining of Sunni Arabs set the stage for a major militant offensive, but factors such as Syria's civil war also played a role, experts say.
Maliki's opponents accuse him of sectarian discrimination against the Sunni minority, centralising power and moving toward dictatorship, while the prime minister insists he is working to keep the country safe.
The militant assault, which began a week ago and is spearheaded by jihadists but involves other groups as well, overran all of one province and swathes of three others in a matter of days.
It poses one of the biggest challenges of Maliki's career.
The prime minister has made major mistakes when it comes to security, for which he is directly responsible as commander-in-chief of the armed forces and acting defence and interior minister, experts say.
"He's appointed every senior officer in the military currently serving, so issues like illegal arrests, torture, extraction of bribes to free detainees, etc. I'd lay at Maliki's feet," said Kirk Sowell, a political risk analyst and publisher of the Inside Iraqi Politics newsletter.
"He is clearly incapable of running the military in a competent manner," Sowell said.
Anthony Cordesman of the Centre for Strategic and International Studies, agreed.
Maliki "has spent the last few years... both corrupting the Iraqi security forces and putting people in (its) command chain (who) are loyal to him," Cordesman said.
And "he has used it systematically to repress the legitimate Sunni opposition."
Security forces carried out numerous operations against Sunni Arab anti-government protest sites, including the demolition of one camp west of Baghdad that set off a chain of events in which the government lost control of all of one city and parts of another.
Iraqi forces have also launched wide-ranging operations that sweep up large numbers of Sunni Arabs said to include the innocent along with the guilty.
"The end result has been to basically make the Iraqi security forces a structure which is extremely ineffective" and "has lost any real morale," Cordesman said.
Security forces performed poorly during the initial assault by militants, with some abandoning vehicles, positions and uniforms to flee.
But they seem to have recovered somewhat from the shock of the onslaught and have begun to retake some areas north of Baghdad.
Most of the areas that have been seized by militants are populated by Sunni Arabs, many of whom are angry with the Shiite-led government over what they view as the unjust targeting of their community by security forces, and the marginalisation of their leaders.
Sunni anger has played a major role in a surge in violence over the past 18 months to levels not seen in years, making it easier for militants to operate and recruit, and reducing residents' cooperation with security forces.
John Drake, a security analyst at AKE Group, said Maliki should have incorporated the Sunni Arab militia known as Sahwa, who fought alongside US forces against militants, into the security forces, and should also have sought to extend the American military presence in Iraq beyond 2011.
And "there should have been more dialogue with people such as senior tribal figures in the central region in order to reach mutual agreements."
But internal and external factors beyond Maliki's control have also contributed to the current crisis.
Sunni Arab obstinance is one issue, with politicians and clerics making "absolutist demands that no Shiite PM would ever agree to, including the formation of autonomous regions with a de facto independent Sunni army that Baghdad would fund," said Sowell.
He also said contentious issues that contributed to the crisis, including de-Baathification, a process aimed at keeping officials from Saddam Hussein's regime out of office that opponents say has been used to target Sunni politicians, "have little to do with Maliki specifically".
The civil war in neighbouring Syria has also been a major factor, bolstering militant groups including the Islamic State of Iraq and the Levant, which has spearheaded the offensive in Iraq, by rallying fighters to their cause and giving them a base of operations and additional combat experience.
Maliki is vying for a third term as premier after April 30 parliamentary polls, but it is unclear if he will weather the storm.
He is likely to need support from Sunni and Kurdish blocs in order to secure re-election during the protracted period of government formation, but faces strong opposition from those communities' leaders.
"I think these events make Maliki's reelection less likely for sure," said Sowell.
"His credibility is shot."