Newly-elected Iraqi President Barham Salih has named veteran Shia politician Adel Abdul Mahdi as prime minister and tasked him with forming a new government, ending months of deadlock after an inconclusive national election in May.

The prime minister-designate - whose appointment must be approved by parliament - now has 30 days to form a cabinet.

That cabinet also needs parliamentary approval.

"I promise to safeguard Iraq's unity and safety," said Salih, as he was sworn in as president earlier on Tuesday.

Since Saddam Hussein was toppled in a 2003 US-led invasion, power has been shared among Iraq’s three largest ethnic-sectarian components. The prime minister has traditionally been a Shia Arab, the speaker of parliament a Sunni Arab and the president a Kurd.

Abdul Mahdi had served as vice president from 2005 to 2011 and as oil minister from 2014 to 2016.

Salih, 58, a veteran Kurdish politician, had served as deputy prime minister under Nouri al-Maliki from 2006 to 2009. He was also the prime minister of the semi-autonomous Iraqi Kurdistan region from 2009 to 2012.

"Today is a remarkable day for Iraq. Democracy won," Rebwar Taha, a lawmaker from the Patriotic Union of Kurdistan, the party that nominated Salih, told Reuters.

Salih routed his main rival Fuad Hussein with 219 votes to 22, dealing a blow to Hussein's main backer, former Kurdish regional president Massoud Barzani who was the architect of the ill-fated Kurdish independence referendum in September 2017.

The independence vote last year saw more than 92 percent of Kurds back secession, but the federal government rejected the poll as "illegal".

Baghdad then imposed economic penalties and sent federal troops to push Kurdish forces out of oil fields in the disputed Kirkuk province that were vital for the autonomous region's economy.

Abdul Mahdi, 76, is a trained economist who left Iraq in 1969 for exile in France, where he worked for think tanks and edited magazines in French and Arabic.

He is the son of a respected Shia cleric who was a minister in the era of Iraq's monarchy, overthrown in 1958.

Abdul Mahdi was nominated by two rival blocs, one led by Shia cleric Muqtada al-Sadr and outgoing Prime Minister Haider al-Abadi and the other by Iran-backed militia leader Hadi al-Amiri and former premier Nouri al-Maliki.

Both blocs claim to hold a parliamentary majority but the dispute has been rendered irrelevant by their choice of the same man to be premier.

"The nomination of Mr Adel Abdul Mahdi came after an agreement between the Binaa bloc and the Islah bloc to nominate him via consensus and not a majority bloc in order to get past the issue of which is the majority bloc," said Ahmed al-Asadi, a spokesman for the Binaa bloc led by Amiri and Maliki.