The last time Masoud Pezeshkian set out to be elected president of Iran, in 2021, Iran’s conservative regime barred him and his entire reformist camp from running.

This time, Iranian authorities allowed the 69-year-old heart surgeon and political veteran onto the ballot as the sole presidential candidate publicly committed to relaxing the country’s strict moral codes regarding women and reviving dialogue with the West.

That Pezeshkian was allowed to run at all indicated that the Iranian establishment considered him to be a safe choice. In turn, his victory on Saturday, with 53% of the vote in an election that saw a surge in turnout, signaled the level of public concern about the hard-line policies that his opponent espoused.

Pezeshkian’s low-key, cautious approach to politics has enabled him to survive while heavyweight political moderates were driven from the political arena . He defeated the conservative candidate Saeed Jalili in the contest to choose a successor to the late President Ebrahim Raisi , who died in a May helicopter crash .

Pezeshkian was a “safe bet” for the regime, “unique in not pledging any concrete commitments, focusing instead on his governing approach while admitting the limits he might face as president,” said Ali Vaez , a director at the Brussels-based Crisis Group. “Votes for him were not necessarily out of hope for the better, but fear for the worse.”

Iran’s president—who is the country’s No. 2 official after the supreme leader—oversees economic policy and appoints high-level decision makers. The supreme leader can block him, as can Parliament, leaving the president with little influence on security and military matters.

In a characteristic gesture, Pezeshkian signaled after the win that he would work with hard-liners—an approach that will be necessary for him to avoid being shut down in a regime where Supreme Leader Ali Khamenei has final say.

“We will extend the hand of friendship to everyone,” Pezeshkian said on state television. “We should use everyone for the progress of the country.”

That approach is informed in part by his own experience in the administration of the reformist President Mohammad Khatami , in which Pezeshkian made a start in politics when the new president appointed him as a deputy health minister in 1997. He served as health minister from 2001 to 2005, as Khatami attempted to liberalize Iran’s elections, only to be blocked by hard-liners.

Nevertheless, Pezeshkian maintains the reputation of an outsider. He was born in western Iran to an ethnic-minority family. He speaks Azeri, the Turkic language of his father, and has promoted its use, making him popular among communities that have often clamored for more autonomy in the Persian-dominated nation.

Pezeshkian got his medical training in the 1980s and treated the wounded on the front lines during Iran’s war with Iraq.

In 1994, while employed as a surgeon and head of a local hospital, he lost his wife and a son in a car crash. He never remarried, raising two sons and a daughter.

In a reflection of Pezeshkian’s low-profile approach, when asked about the crash in a May interview on state television during the campaign, he demurred.

“What’s to tell about an accident?” he said. “The car turned over.”

“You don’t have a memory of it in mind?” the interviewer asked.

“No, I don’t,” he said. “The one accident that should not have happened, happened.”

He campaigned with his daughter at his side, a reminder of the family calamity and a subtle, humanizing contrast to the public image of his opponent, Jalili, as a dogmatic defender of the Iranian system.

Pezeshkian has been a lawmaker since 2008, representing a province in his native region during the presidencies of the hard-liner Mahmoud Ahmadinejad and his moderate successor, Hassan Rouhani , including a stint as deputy parliamentary speaker.

He criticized a deadly crackdown on protesters disputing the legality of Ahmadinejad’s re-election in 2009, but often avoided confrontational statements about repression by the Iranian regime. He initiated a run for president in 2013 but dropped out early to clear the way for another reformist-backed candidate who later dropped out as well.

Just as he was little-known in Iran before the election campaign, he wasn’t well-known in the West, according to Western officials. U.S. officials said they expected Pezeshkian would keep open a channel of dialogue established with the Raisi government to keep a lid on tensions.

In 2022, after nationwide protests erupted following the death of Mahsa Amini, who had been accused of violating the Islamic Republic’s strict dress code, Pezeshkian called for an investigation into the young woman’s death but said it was unclear whether she had died as a result of police brutality, as her family said.

In public statements, Pezeshkian tried to accommodate both sides of the divide. “We should have done better,” he said.

When Raisi died in May, two former moderate presidents, Mohammad Khatami and Hassan Rouhani, were already out of the picture—both marginalized for years by the conservative establishment. Ali Larijani , a moderate former Parliament speaker, was barred, in line with Khamenei’s trend of sidelining politicians outside the conservative camp.

Pezeshkian slipped through , the beneficiary of an apparent effort to get more voters to cast ballots after less than half of voters turned up for the elections for president in 2021 and for Parliament in March this year. The low 2021 turnout and the wave of protests in 2022 sent the message that a majority of Iranians were now rejecting the regime.

A runoff with the conservative candidate Jalili drove voters back to the ballot box. Turnout was 49.8%, up from 40% in the initial round of the election .

In a message posted on X, Khamenei hailed the resurgent turnout. He called it a “great move in confronting the manipulated fuss of boycotting the elections, which the enemies of the Iranian nation had set in motion to induce despair and deadlock.”

Pezeshkian had pitched himself as the antidote to the return of hard-liners. Yet he carefully avoided crossing the regime’s redlines. He criticized the excesses of the morality police but hasn’t called for an end to the compulsory hijab.

During the campaign, the reformist also stuck to the regime’s core foreign-policy principles. He zealously pledged his loyalty to the political system, praising the late military commander Qassem Soleimani , who had engineered Iran’s alliances with Middle East militias before being killed in a U.S. strike in 2020 .

Pezeshkian also made it clear he has no intention to change Iran’s refusal to recognize Israel, a pillar of the Islamic Republic since its founding in 1979. “God willing,” he said, “we will try to have friendly relations with all countries except Israel.”

Following his win Saturday, Pezeshkian canceled a press conference to make time to meet with Khamenei, and offered another gesture of loyalty to the conservative theocracy: He scheduled his victory speech to take place at the shrine of the founding leader of the Islamic Republic, Ayatollah Ruhollah Khomeini .

Write to Benoit Faucon at benoit.faucon@wsj.com

Corrections & Amplifications undefined Ali Larijani is a moderate former Parliament speaker. An earlier version of this article incorrectly said his first name was Ari.