Another candidate for the post was Fuad Hussein. None of the two managed to get the required votes in the first round of voting.
In the second round, Hussein dropped out of the race and Barham Salih was elected president.
He replaced Fuad Masum who had served as Iraq’s president since July 2014.
The presidency, traditionally occupied by a Kurd, is a largely ceremonial position in Iraq.
Under Iraq’s constitution, Salih - a 58-year-old, British-educated engineer who has held office in both the Iraqi federal and Kurdish regional governments - had 15 days to invite the nominee of the largest parliamentary bloc to form a government. He chose to do so less than two hours after his election, Reuters reported.
A former vice president, oil minister and finance minister, Abdul Mahdi now has 30 days to form a cabinet and present it to parliament for approval.
He faces the daunting tasks of rebuilding much of the country after four years of war with Daesh terrorists and healing its ethnic and sectarian tensions.
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.