Iraq's new President Barham Saleh has named veteran Shia Islamist politician Adel Abdul Mahdi as prime minister-designate, ending months of deadlock.
Mr Saleh, a Kurdish former deputy prime minister, was elected to the largely ceremonial post by MPs late on Tuesday.
Soon afterwards he asked Mr Abdul Mahdi, who has served as vice-president and oil minister, to form a government.
The French-educated economist is the nominee of the two Shia-led blocs that won the most seats in May's elections.
He will have to oversee the reconstruction of Iraq following the four-year battle against the jihadist group Islamic State (IS), which left tens of thousands of homes and business destroyed and displaced more than three million people.
How was the president chosen?
Under a de facto power-sharing deal agreed in Iraq after the US-led invasion that overthrew Saddam Hussein in 2003, the speaker of parliament is always a Sunni Arab, the prime minister a Shia Arab, and the president a Kurd.
There were 20 candidates for the presidency, but it was effectively a contest between the nominees of the semi-autonomous Kurdistan Region's two main parties - the Kurdistan Democratic Party and the Patriotic Union of Kurdistan.
Mr Saleh was the PUK's choice, while the KDP backed Fuad Hussein, the longtime chief-of-staff to former Kurdistan regional president Massoud Barzani.
In the end, Mr Saleh won 219 of the votes cast by the 273 MPs who attended Tuesday's session, according to the Speaker Mohammed al-Halbousi.
Mr Saleh was reportedly the preferred candidate of MPs because of his perceived stance on independence for the Kurdistan Region, a year after the federal government and judiciary rejected the result of a referendum called by Mr Barzani in which residents overwhelmingly backed secession.
Who is Mr Saleh?
The 58 year old joined the PUK in 1976, when it was an underground organisation, and fled Iraq four years later for the UK.
After studying for a PhD in statistics in the UK, he became the PUK's spokesman there. He then served as the Kurdish envoy to the US from 1991 to 2001, before returning to Kurdistan to lead a PUK-led government.
Between 2004 and 2005 Mr Saleh was one of the deputy prime ministers in Iraq's interim government. He also served in that role from 2006 to 2009. He was then prime minister of the Kurdistan Regional Government until 2012.
In 2017, he broke away from the PUK after the death of its founder, Jalal Talabani, and formed a new Kurdish opposition party, the Coalition for Democracy and Justice. But last month, Mr Saleh resigned from the CDJ and rejoined the PUK.
Why did he ask Mr Abdul Mahdi to be PM?
Under Iraq's constitution, Mr Saleh had 15 days to invite the nominee of the largest bloc to form a government. But he immediately tapped Mr Abdul Mahdi.
He was the consensus candidate of the two Shia-led blocs both claiming to be the largest in parliament - one led by the populist cleric Moqtada Sadr and outgoing Prime Minister Haider al-Abadi, the other by the Iran-backed paramilitary leader Hadi al-Amiri and former Prime Minister Nouri Maliki.
Mr Sadr welcomed the compromise, tweeting: "Iraq is bigger than the biggest bloc."
Who is Mr Abdul Mahdi?
The 76 year old fled Iraq in the 1960s after being condemned to death for his political activities, and settled in France. There, he gained a PhD in economics, worked for think-tanks and edited magazines.
After flirting with Maoist politics, he joined the Supreme Islamic Iraqi Council - a powerful Shia Islamist organisation with close ties to Iran.
He returned to Iraq after Saddam was ousted, and as finance minister in the 2004-5 interim government he persuaded international creditors to write off Iraqi debt.
Mr Abdul Mahdi was tipped to become prime minister after the 2005 elections, but he was instead chosen to be vice-president - a position he held until 2011.
He also served for two years as oil minister under Mr Abadi, resigning in 2016 amid what he called "an atmosphere of anxiety and chaos" triggered by the decision to replace political appointees in the cabinet with unaffiliated technocrats.
Mr Abdul Mahdi was a member of SIIC until last year, when its leader Ammar al-Hakim left and established a new party called the National Wisdom Movement.