Iraq's Prime Minister-designate Mohammed Allawi has withdrawn his candidacy for the post, accusing members of the country's fractured parliament of standing in his way and prolonging a months-long political crisis.

Allawi's move on Sunday came hours after legislators failed for the second time this week to approve his cabinet of independents amid political infighting in a country that has been rocked by months of anti-establishment protests that forced the resignation of Prime Minister Adel Abdul Mahdi.

More:

"I tried with all possible ways to save our country from sliding into the unknown and to solve the current problem. But during the negotiations, I ran into many things unrelated to the country's interests," Allawi said in a statement presented to President Barham Salih.

"Some sides negotiated with the mere aim of making gains without paying any attention to the national cause or heeding the blood of the martyrs who fell during protests seeking the change of conditions," he added.

More than 500 people have been killed and 30,000 wounded since the mass protests seeking an overhaul of the country's political system began in October in the capital, Baghdad, and several southern cities, with rights groups accusing security forces of using excessive force against demonstrators.

Allawi's resignation a month after he was selected for the post - and two months after Abdul Mahdi, who remains a caretaker prime minister, stepped down - plunges the country into more uncertainty.

Salih will begin consultations to choose a new candidate for prime minister within 15 days.

But Iraq could end up without a prime minister in the meantime if Abdul Mahdi also quits on Monday. Late on Sunday, he issued a statement denying social media reports that he wanted to stay on, saying he would announce his intentions on Monday, which would have been the last day for Allawi to get his proposed cabinet approved by parliament.

The weeks leading up to Sunday's parliament session was marred by delays and political infighting as Allawi insisted he would select his own ministers - a move that alienated Kurdish and Sunni parties in particular and sparked threats of boycott.

"What Allawi set out to do was form an independent and technocratic cabinet that would be able to address some of the protesters' demands and to try to pass some of the reforms that are seen as necessary to put an end to this crisis," Al Jazeera's Simona Foltyn, reporting from Baghdad, said.

"But such a cabinet would really go against the way the Iraqi system has functioned for the past 17 years, one that is largely beholden to the political parties."

Known as muhasasa, the system was introduced in Iraq after the US-led invasion in 2003 to provide proportional government representation among Iraq's various ethno-sectarian groups.

"The way it works is that the ministerial positions are divided up between the major political parties that represent the Shias, the Sunnis and the Kurds and there are unwritten rules about how this should happen," Foltyn said.

"For example, the Kurds tend to get the finance ministry, the Sunnis the defence ministry and the Shias the interior ministry. What Allawi tried to do is appoint candidates who aren't from these political parties, who are not beholden to their interests, and that was something that wasn't accepted."

Finding a successor

The anti-government demonstrators demanding an end to corruption and better economic opportunities had rejected the choice of Allawi for prime minister, saying he is too close to the elite against which they have protested.

They have backed instead Alaa al-Rikaby, a pharmacist who has emerged as a prominent activist in the protest hotspot of Nasiriya south of Baghdad.

Iraq's president, however, intends to propose intelligence chief Mustafa al-Kazimi as prime minister, political sources told AFP news agency.

Populist Shia Muslim leader Muqtada al-Sadr, regarded as a backer of the protest movement before he rescinded his support last month, hailed Allawi's decision as one taken "for the love of Iraq".

He condemned other "corrupt" politicians for "holding the country hostage".

Allawi's successor will inherit the daunting task of reconciling the government, as well as bridge major rifts between rival factions over ties with the United States and Iran, two longtime foes who are also the Iraqi government's main allies now and vie for influence there.

Parties representing the Shia majority approved a non-binding motion in parliament in January demanding the departure of all 5,200 US troops stationed in Iraq.

Amid the latest political twist, two rockets landed in Baghdad's Green Zone, which houses government buildings and foreign missions, said the Iraqi military.

The rockets landed near the US embassy, a security source told Reuters news agency, in the 20th attack against US assets in the country in four months.

None of the attacks since October targeting either the US embassy or its troops stationed across Iraq has been claimed but Washington has accused Iran-backed groups within the Popular Mobilisation Forces (PMF) of being behind them.

On January 3, a US air raid assassinated top Iranian military commander Qassem Soleimani near Baghdad's international airport, sparking fears of all-out war with Iran. The attack also killed Abu Mahdi al-Muhandis, the PMF's deputy commander.

Five days later, Iranian missiles hit two bases in Iraq housing US troops but caused no fatalities.