BAGHDAD — He is best known to American officials as the firebrand cleric and sectarian Shiite militia leader who made life miserable for Iraq’s Sunni minority and for U.S. military and political planners in the chaotic, violent early days after the overthrow of Saddam Hussein.

Fifteen years later, after the surprising results of Iraq’s elections Sunday, Muqtada al-Sadr looks to have a new role: kingmaker.

In an upset for U.S.-backed Prime Minister Haider al-Abadi’s Victory List, the Sa’iroon alliance of Mr. al-Sadr and Iraqi communists held the lead Monday night in six of Iraq’s 18 provinces and came in second in four others.

Election officials, basing their estimates Monday evening on 91 percent of the votes cast in 16 of Iraq’s 18 provinces where Mr. al-Sadr had campaigned, said it was virtually certain that his election group had won the most votes in the closely watched but sparsely attended poll.

Mr. al-Abadi, who ran as the leader who helped defeat Islamic State but faced popular unhappiness over the state of the economy and state services, struck a conciliatory tone despite his thrashing at the polls. There is still a good chance, election analysts said, that he could keep his post in coalition negotiations aimed at excluding Iranian-backed militia leader Hadi al-Ameri and his Conquest Alliance from dominating the Iraqi parliament.

“We are ready to work and cooperate in forming the strongest government for Iraq that’s free of corruption,” Mr. al-Abadi said.

The early ballots of some 700,000 security personnel and diaspora remain uncounted, meaning Mr. al-Abadi could get a boost.

But it is Mr. al-Sadr’s unexpectedly strong showing that has been the story of this vote. While still able to mobilize his Shiite base, he has evolved considerably in the years since the 2003 U.S. invasion. He has refashioned himself as an Iraqi nationalist critical of corruption, opposing an overbearing role for Shiite Iran in Iraqi affairs and even reaching out to Sunnis and secularists in recent years to broaden his political base.

“We are moving to a free and independent Iraq,” Mr. al-Sadr said just before Saturday’s voting in a televised address from his office in the Shiite city of Najaf. “We are going to move to an Iraq safe from corruption, terrorism and militias.”

The electoral sweep for Sa’iroon — a youth-oriented bloc that emphasized social inequality over religious grievances — puts the 44-year-old Mr. al-Sadr, often called an Arab nationalist and thus an opponent of both the U.S. and Iran, in a position to determine Iraq’s next leader.

Mr. al-Sadr has led two uprisings against U.S. forces in Iraq. The George W. Bush administration once labeled him and his dreaded Mahdi Army as the greatest threat to Iraqi stability.

Because he was not on the ballot as a candidate, Mr. al-Sadr is prevented from leading the next government. But the strong showing in early returns underscored voters’ frustration with prior governments — even with the defeat of Islamic State and the relative security that reigns in much of the country.

Despite his long, checkered resume, Mr. al-Sadr even got credit from some voters for offering a new path forward.

“Most of the candidates in this coalition were new and didn’t participate in the political process before,” said Amer Ahmed, 30, an employee of the Iraqi electric company and a Sa’iroon supporter. “The young generation basically formed their own electoral list. … We will transform the government and society.”

Young revolt

In a country where the median age is 19, only 20 of the 328 Iraqi lawmakers in the outgoing legislature are younger than 40.

Mr. al-Abadi may also have been hurt by another factor: voter apathy. Frustration with traditional politics and a complicated new voting system translated into the lowest turnout in Iraq since Saddam was ousted in 2003. Iraq’s Independent High Electoral Commission said turnout was 44.52 percent, significantly lower than in previous elections.

Still, analysts said, the regional strategic implications of the results are significant.

Mr. al-Sadr, a Shiite leader, was the unlikely beneficiary of Saudi Arabian largesse in an attempt to dilute the strength of the candidate seen as Iran’s pick, Mr. al-Amiri and his Fateh group, which were on track to finish second in the vote.

Just a year ago, Mr. al-Amiri fielded former fighters from Iranian-backed militias to the Iraqi national army and a U.S. coalition to battle Islamic State. His prominent role in the fight reaped electoral benefits among Shiite hard-liners for “protecting the honor” of Iraq.

“The biggest surprise was the lead of Sa’iroon rather than al-Abadi’s List. It is an obvious indicator of the American-Saudi support to Sa’iroon,” said Ali Bashar, a political scientist at Bayan University in Irbil. “They contained contradicting ideological parties, like communists and liberals, under a single frame, non-Islamic in appearance, although it is.”

Mr. al-Sadr, who comes from a line of prominent Shiite clerics and whose father was killed by the Saddam regime, has been a player on the Iraqi political scene for more than a decade, without ever being a dominant force, in large part from his passionate political base among lower-income Shiites in Baghdad and other areas.

He may have sown the seeds two years ago for his strong showing Sunday when he led a populist protest movement focusing on kitchen-table issues such as poor government services and the lack of jobs. In April 2016, Mr. al-Sadr inspired thousands of supporters who stormed Baghdad’s highly fortified Green Zone to demand political reforms, briefly forcing Mr. al-Abadi to recall troops from the front lines fighting Islamic State to restore order in the capital.

Despite Mr. al-Sadr’s changed message, some fear the results put Iraq squarely in the middle of Washington-Tehran disputes, especially because of President Trump’s decision to pull out of the deal with Britain, France, China, Russia and Germany to contain Iran’s nuclear program.

“Personally, I am afraid of the psychological instability of [Mr. al-Sadr], and his stances waver too easily,” said Baghdad physician Abderrezak al-Nuaimi, 33. “It’s going to be difficult to get together a coalition. I think the winning list of Sadrists might be forced to form a narrow government by themselves unless the Americans prepare the ground carefully.”

The Iranian Foreign Ministry issued a statement hailing the election as a victory over unidentified “terrorist” elements.

“By participating in the election, the Iraqi nation once again tried to strengthen their achievements and victories in the counterterrorism campaign,” Foreign Ministry spokesman Bahram Qasemi told reporters.

But some Iraqis worry that a breakdown in the coalition talks could lead to more violence as party politics turns into a power struggle among armed groups.

“I am afraid of the repetition of violence against civilians,” said Aws Ibrahim, 22, a geology student at Mosul University. “All the parties have armed wings, and now they are disputing over how to divide the cake.”

Mr. Ibrahim is particularly worried that Nouri al-Maliki, the previous prime minister who U.S. officials see as a divisive and sectarian figure, will turn to violence after failing completely at the ballot box.

Many blamed government corruption under Mr. al-Maliki for the collapse of the Iraqi army in the face of the 2014 Islamic State capture of Mosul, Tikrit and other territory. Sunnis blamed the al-Maliki government for substandard education, health care and infrastructure in their areas, which constitute 35 percent of the country.

Meanwhile, jubilant Sa’iroon supporters celebrated their get-out-the-vote operation and the rejection of Iranian domination by much of the Shiite electorate.

“The celebrations of Sadrists in Baghdad was so huge today and their anti-Iran slogans were blatant,” said Ali Bashar, a political scientist at Bayan University in Irbil. “Sa’iroon support to al-Abadi could fade away as they were Baghdad’s biggest list, but if the USA is able to contain the Sadrists somehow, they are likely to present a prime minister [Mr. al-Abadi] with another term.”

Regardless of which candidate gets the prime minister’s post, many are just grateful that the more militant groupings such as Fateh appear to be locked out of the negotiations.

“Nobody remembers the bad qualities of those on the head of this list who played with people’s feelings under the name of ‘fight and martyrdom,’” said Thaer Qasim Jaber, 37, a graphic designer in Baghdad.