Iraqi lawmakers on Thursday elected former minister Abdul Latif Rashid as the country's next president, defying threats of further violence following a barrage of rocket attacks earlier in the day and taking a key step toward ending a crippling political vacuum.

At least nine rockets targeted Iraq’s Parliament inside the heavily fortified Green Zone, the seat of the government, ahead of a much-anticipated session where lawmakers forged ahead with the formation of the next government despite the political crisis. At least five people were wounded.

Per Iraqi law, the president must call on Parliament’s largest bloc to nominate a premier. Iraq’s Parliament seats 329.

IRAQ SUMMONS IRANIAN AMBASSADOR FOLLOWING DEADLY BOMBING CAMPAIGN

The Iran-backed Coordination Framework, composed of largely Shiite parties, has named Mohammed Shia al-Sudani as their premier-designate, after submitting a formal letter claiming to be the largest bloc on Thursday.

Latif, 78, was elected with a vote of 162 out of 261 votes cast. He served as water resources minister from 2003 until 2010 and has been an advisor to the head of state since. Outgoing President Barham Saleh reportedly walked out of the parliament building as the votes were tallied. He lost with 99 votes.

Iraqi law gives Latif 15 days to nominate a prime minister, likely in this case al-Sudani, to present his cabinet line-up to Parliament to face another vote.

In Iraq's power-sharing system, the presidency is reserved for Kurdish groups to nominate while the premiership falls under Shiite blocs. The speaker of parliament is a Sunni.

Abdul Latif Rashid

Newly elected Iraqi President Abdul Latif Rashid gives a speech at the 37th FAO Conference in Rome, Italy, on June 25, 2011. (AP Photo/Pier Paolo Cito, File)

Political wrangling and repeated crises prevented the appointment of a new government after federal elections were held in October 2021. The stalemate has been driven largely by a tense political rivalry between influential Shiite cleric Muqtada al-Sadr, and former Prime Minister Nouri al-Maliki, who is backed by Iran.

The real test going forward for the crisis-hit country’s bickering factions will be in officially voting in the new prime minister and cabinet lineup with al-Sadr ostensibly out of the political process after he withdrew his lawmakers from Parliament and since announced his withdrawal from politics.

The rocket attack delayed but did not postpone the legislative session.

At least one rocket landed close to the parliament building ahead of the session, Iraqi officials said. More fell in other areas inside the Green Zone perimeter.

ISIS IS THREAT TO ENTIRE HUMAN RACE, IRAQI FOREIGN MINISTER SAYS IN EXCLUSIVE INTERVIEW

At least five people were wounded in the attack — three were civilians and two were military personnel — security officials said without giving more details. The culprits were not immediately known.

The attacks, which appeared to be an attempt to derail the session, occurred after the Coordination Framework, an alliance made up of mostly Iran-backed Shiite parties and led by al-Maliki, delivered a formal letter claiming to be the largest bloc in Parliament.

The alliance named Mohammed Shia al-Sudani as their nominee for the premiership.

Al-Sadr had previously rejected al-Sudani's candidacy and directed his supporters to storm the parliament on June 30 to derail his nomination.

Al-Sadr’s party won the largest number of seats in the October 2021 federal election, but he ordered his lawmakers to resign after failing to secure a quorum to vote in a government that would exclude his Iran-backed rivals. Violent street fighting erupted for 24 hours between al-Sadr's supporters and Iraqi security forces on Aug. 29, bringing the country to the brink of a civil war.

US-BACKED FIGHTERS RESCUE TENS OF THOUSANDS OF WOMEN AND CHILDREN IN RAID ON ISIS AL-HOL CAMP

Many feared protests by the followers of al-Sadr, a political opponent of the Framework, ahead of Thursday's session.

Mark Bryson-Richardson, Britain’s ambassador to Iraq, called the rocket attack, "completely unacceptable."

"Violence has no part in the political process and state institutions must be allowed to operate," he tweeted.

The officials spoke on condition of anonymity because they were not authorized to brief the media.

It was not the first time rocket attacks have targeted the parliament building as lawmakers prepared to attend a session.

ON 9/11 ANNIVERSARY, I THINK ABOUT SERVING IN IRAQ AND NOW CONGRESS

On Sept. 28, three rockets targeted the Green Zone as a session was convened to renew confidence in parliament speaker Mohammed al-Halbousi.