BEIRUT, Lebanon — For nearly five months, Iraqi politicians have wrangled over the shape of their new government.

The bloc led by Moktada al-Sadr, the former Shiite militia leader and longtime American enemy, won the most votes in the May election. He had rebranded himself as an “Iraq First” populist, vowing to fight corruption, opposing both American and Iranian intervention, and promising a new nonsectarian politics.

This week, the wrangling ended and Iraqis got new evidence that perhaps he meant what he said.

On Wednesday, an honor guard stood at attention as Iraq’s new head of state, President Barham Salih, entered the presidential palace in Baghdad’s Green Zone, a day after designating Adel Abdul Mahdi as prime minister.

Both leaders, chosen by consensus in Parliament on Tuesday, were widely seen as capable technocrats. Mr. Abdul Mahdi, who will take the top job, is a former vice president who is unaffiliated with any party and has a reputation for secularism. Mr. Salih, whose post is largely ceremonial, is a Kurdish politician who favors working with the central government in Baghdad.