The mayor of Tehran, seen as a pragmatist, came in second with 18 percent of the vote, but the four hard-line conservatives aligned with the supreme leader, Ayatollah Ali Khamenei, finished at the back of the pack. That punishing at the polls indicated that Iranians were looking to their next president to change the tone, if not the direction, of the nation by choosing a cleric who served as the lead nuclear negotiator under an earlier reformist president, Mohammad Khatami.

Though Mr. Rowhani’s election was not expected to represent a break with Iran’s nuclear policies, voters linked him with the Khatami era, when Iran froze its nuclear program, eased social restrictions and promoted dialogue with the West, giving reformers hope that he would try to lead Iran out of international isolation and religious reaction.

But if the election was a victory for reform and middle class voters, it also served the conservative goals of the supreme leader, restoring at least a patina of legitimacy to the theocratic state, providing a safety valve for a public distressed by years of economic malaise and isolation, and returning a cleric to the presidency. Mr. Ahmadinejad was the third noncleric to hold the presidency, and often clashed with the religious order and its traditionalist allies.

The question for Western capitals is whether a more conciliatory approach can lead to substantive change in the conflict with Iran over its nuclear program.

Ayatollah Khamenei still holds ultimate power over the nation’s civil and religious affairs, including over the disputed nuclear program. Sharif Husseini, a member of Parliament, warned Saturday that “nothing would change” in Iran’s nuclear policies. “All these policies have been decided by the supreme leader,” he was quoted as saying by the Iranian Student News Agency.