An alliance headed by a former Shia militia chief who led two uprisings against the US-led invasion of Iraq has won the parliamentary elections.
But Moqtada Sadr, who is also staunchly opposed to Iranian involvement in the country, cannot become prime minister as he did not stand as a candidate.
However, he is expected to play a major role in forming the new government.
The party of outgoing PM Haider al-Abadi was pushed into third place, behind a pro-Iranian alliance.
These elections were the first since Iraq declared victory over the Islamic State group in December. Some 5,000 American troops remain in Iraq supporting local forces, which were fighting IS.
Final results released by the election commission early on Saturday showed Mr Sadr’s Saeroun bloc won 54 seats, compared to Prime Minister Abadi’s 42. The pro-Iranian Fatah alliance went into second place with 47 seats.
But Mr Sadr’s alliance – formed of his own party and six mainly secular groups, including the Iraqi communist party – failed to win more than 55 of the 329 seats up for grabs, so he faces the complex task of drawing together a governing coalition.
Mr Sadr, who made his name as a militia chief fighting US forces after the 2003 invasion of Iraq, has reinvented himself as an anti-corruption champion, and also campaigned on a platform of investing in public services.
The defeat of Mr Abadi’s alliance came as many voters expressed dissatisfaction with corruption in public life.
Despite his poor showing, he may yet return as prime minister after negotiations which must now be completed within 90 days to form a new government.
Whoever is named prime minister will have to oversee the reconstruction of Iraq following the battle against IS, which seized control of large parts of the country in 2014.
International donors pledged $30bn (£22bn) at a conference in February but Iraqi officials have estimated that as much as $100bn is required. More than 20,000 homes and businesses were destroyed in the second city of Mosul alone.
More than two million Iraqis are still displaced across the country and IS militants continue to mount deadly attacks despite having lost control of the territory they once held.
Turnout at the 12 May election was only 44.5% – much lower than in previous polls.
Shia cleric Moqtada Sadr’s bloc wins Iraq elections}