But no matter how large and sweeping any victory might be, Mr. Rouhani, 68, will face considerable headwinds, both at home and abroad.
While he accomplished his goal of reaching a nuclear agreement with the United States and Western powers, Iran has not enjoyed the economic benefits he predicted because of lingering American sanctions. He badly needs to demonstrate progress on overhauling the moribund economy.
Whoever wins must also deal with an unpredictable and hawkish Trump administration that this week only reluctantly signed the sanctions waivers that are a central element of the nuclear agreement. At a summit meeting this weekend in Saudi Arabia between President Trump and leaders of predominantly Muslim countries, Iran was pointedly not invited.
The Trump administrationâs national security officials are on record as considering Iran the source of most of the Middle Eastâs troubles, while the Republican-controlled Congress is not about to loosen the unilateral sanctions that are frightening off foreign banks and businesses.
Mr. Raisi, 56, is a hard-line judge who campaigned as a corruption fighter and called on Iran to solve its economic problems without help from foreigners. He presented himself as a champion of the poor and the pious.
Urban Iranians voted in high numbers, largely against him.
Responding to campaigns on social media led by prominent intellectuals, actresses, Instagram stars and sports figures, about 40 million of the 56 million Iranians who live in or near cities turned out to vote.
That reflected the bitter lesson of 2005, when many people boycotted that yearâs election out of disillusionment with the hard-linersâ thwarting of the reformist agenda of the outgoing president, Mohammad Khatami. That allowed the Islamic Revolutionary Guard Corps and conservative clerics to elect Mahmoud Ahmadinejad, the Holocaust-denying former president.