HASSAN ROUHANI will be Iran’s next president not only because he was picked by a majority of Iranian voters but also because the country’s supreme leader, Ayatollah Ali Khamenei, chose to accept his victory. That decision surprised us and some Western experts on Iran, but in retrospect there was good reason for it. Had the Islamic regime falsified the results and blocked Mr. Rouhani, it would have risked a repeat of the popular uprising that followed the 2009 election, when followers of reformist candidates concluded — probably rightly — that the reelection of hard-liner Mahmoud Ahmadinejad had been rigged.

At the same time, Mr. Rouhani was in the presidential race because he had been judged to be a reliable follower of the supreme leader, unlike other moderate and reformist candidates who were banned from the ballot. Though he criticized the government’s recent handling of negotiations on Iran’s nuclear program, he made clear that he supports the program and that decisions about it would lie with Mr. Khamenei. At a press conference Monday, Mr. Rouhani rejected the suspension of uranium enrichment, mandated by multiple U.N. Security Council resolutions, and repeated Tehran’s past rhetoric that an improvement in relations with the United States would require that “they have to recognize our nuclear rights [and] put away bullying policies against Iran.”

As president, Mr. Rouhani could well make it easier for Tehran to resist sanctions and other international pressure without slowing its progress toward a nuclear bomb, its intervention in Syria’s civil war or its sponsorship of terrorism. With his crude denials of the Holocaust and promises to wipe Israel off the map, Mr. Ahmadinejad helped the United States and its allies rally support for measures that have reduced Iran’s oil earnings by half and isolated it from the world. Mr. Rouhani, in contrast, has boasted of his record, as nuclear negotiator from 2003 to 2005, of heading off sanctions through skillful diplomacy even as more centrifuges were installed. His more moderate face has already prompted calls for the Obama administration to sweeten its proposals for compromise with the regime.

It’s possible, though unlikely, that Mr. Khamenei will reverse himself and support such a compromise; if so, Mr. Rouhani will be easier to work with than the current nuclear negotiator, Saeed Jalili. More likely, the president’s main forum will be domestic. Young Iranians will be counting on him to ease the repression of morals police, improve the status of women and free political prisoners. In particular, many who supported him will expect him to release the leaders of the 2009 Green movement, Mir Hossein Mousavi and Mehdi Karroubi, who remain under house arrest.

The election demonstrated that a majority of Iranians continues to yearn for a freer society and reject the reactionary policies of Mr. Khamenei and his clique of hard-line clerics. If Mr. Rouhani is not allowed to take steps to answer those aspirations, both he and the regime could face another popular challenge.