TEHRAN—Iranian authorities extended the voting hours to secure a high turnout in Friday’s presidential elections in a process heavily skewed in favor of hard-liners, as Tehran negotiates the revival of an international nuclear deal that would free the country’s economy from crushing U.S. sanctions.

Millions of Iranians planned to boycott the vote after the country’s election supervisory body disqualified nearly all nonconservative candidates. On the ballot are four choices, including an ultraconservative cleric hostile to the U.S. and Western powers, who emerged as the front-runner after the mass disqualification of candidates.

After a poor turnout through the early afternoon, lines started forming at many polling stations in the capital Tehran as the sun set and temperatures dropped. At 7.30 p.m. local time, approximately 22 million people, or 37% of eligible voters, had cast ballots, according to the semiofficial Fars news agency.

The last presidential election in 2017 had a turnout of 73%. Iranian authorities have traditionally touted high election turnouts as evidence of the Islamic Republic’s enduring legitimacy among its people.

Voters registered to cast their vote Friday.

Voters registered to cast their vote Friday.

The Interior Ministry said it would extend voting if necessary until 2 a.m. local time, partly because of purported technical errors in some polling stations. It isn’t unusual for Iran to extend voting hours.

Supreme Leader Ali Khamenei called on Iranians to vote to strengthen the system when he cast his ballot early on Friday. “Every single vote counts,” Mr. Khamenei said in televised remarks. “Today belongs to the people. Showing up at the ballot box and casting your vote helps build the future.”

Ahead of the vote, Mr. Khamenei blamed a predicted low turnout on foreign media.

Iran’s political factions are roughly divided into two main camps: right-wing hard-liners and liberal reformists, with moderate pragmatists, such as the current president, Hassan Rouhani, staking out the middle ground.

The vetting process narrowed the choice for moderates and reformists and exacerbated a feeling among many Iranians of being sidelined by Iran’s authoritarian, clerical establishment. Polls show that election is now essentially a two-person contest between conservative Ebrahim Raisi and centrist Abdolnaser Hemmati, the only non-conservative candidate.

Conservative Ebrahim Raisi is the front-runner in the Iranian election.

Conservative Ebrahim Raisi is the front-runner in the Iranian election.

The election takes place as Iran and the U.S. are negotiating terms to revive the 2015 multilateral nuclear deal, which the Trump administration exited in 2018 before reimposing harsh economic sanctions. Since April, Iranian, American, European, Russian and Chinese negotiators have met in Vienna to agree on a way for the U.S. to return to the nuclear agreement and lift sanctions on Iran, and to roll back Iran’s recent breaches of key limitations on its nuclear enrichment activities, stipulated in the accord.

Iran’s foreign policy, in particular its relationship with Washington, is determined by the supreme leader. But the country’s president can set the direction of Iran’s foreign-policy priorities and influence the supreme leader, as Mr. Rouhani did when he convinced Mr. Khamenei to support negotiations that led to the 2015 accord.

Mr. Raisi, the front-runner, is the country’s chief justice and is close to Mr. Khamenei, whose suspicion of the U.S. and Western powers he shares. He has come out in support of the nuclear deal, echoing the supreme leader’s stance.

As Mr. Khamenei supports reviving the deal, a change in presidency is unlikely to dramatically affect Tehran’s position in the talks, particularly as any economic benefit from a lifting of U.S. sanctions would boost Mr. Raisi early in his term.

Mr. Hemmati also has said he would invite Foreign Minister Javad Zarif to join his cabinet, either in the same role or as vice president, a sign that he intends to continue the current administration’s focus on improving Iran’s foreign relations and support for nuclear diplomacy.

Abdolnaser Hemmati, a former central bank chief who has cast himself as a reform-friendly moderate, is the main challenger to Mr. Raisi.

Abdolnaser Hemmati, a former central bank chief who has cast himself as a reform-friendly moderate, is the main challenger to Mr. Raisi.

In recent weeks, the delegations in Vienna have made a final push to get as close as possible to an agreement before the Iranian elections to ensure that the transition to a new administration in Tehran causes as little delay and uncertainty as possible. Some European diplomats hope to wrap up negotiations by early July, before a new president takes office.

The revival of the nuclear deal wasn’t a central election issue in debates and campaigning leading up to the election. A new president would have to follow the directions of the supreme leader, and candidates across the political spectrum agree that staying in the accord to ensure a lifting of U.S. sanctions is in Iran’s interest. For many, the deterioration of the economy was the primary concern.

Mahmoud Ebrahimi Saniabadi, 33 years old, said he had come out to vote because he followed the supreme leader’s guidance, and that voting ensured that Iran remained not only Islamic but also a republic. He had cast his ballot for Mr. Raisi, he said, because he trusted him to improve Iranians’ livelihoods. “Standing in line for chicken or oil is beneath Iranians,” Mr. Saniabadi said.

On Friday, Mr. Raisi sought to address some of those concerns. “People are right to be upset because of some shortages and problems,” he said. “But they shouldn’t be upset with the ballot box,” Mr. Raisi told reporters Friday morning after casting his ballot at a mosque in a southern suburb of Tehran.

The 60-year-old Mr. Raisi has little political experience but is known as a hard-liner who during a long career in the judicial system has presided over oppression of political dissent and the mass arrest of opposition activists.

Supporters of Mr. Raisi during an election campaign rally in Tehran.

Supporters of Mr. Raisi during an election campaign rally in Tehran.

In Mr. Raisi’s stronghold, the conservative eastern city of Mashhad, banners and posters sought to rally voters by invoking Maj. Gen. Qassem Soleimani, the highly popular top military commander killed in a U.S. drone strike in Iraq last year. One poster on the city’s metro featured a photo of Gen. Soleimani and compared the voting booth to the battlefield: “Don’t leave the field empty,” it said.

Mr. Hemmati, is a former central bank chief who has cast himself as a reform-friendly moderate backing more social and political freedoms for Iranians. He also has limited political experience but the 64-year-old is closely associated with the outgoing administration of Mr. Rouhani, a moderate who has now hit his two-term limit.

For Mahmoud Shojaeeu, a 37-year-old computer expert in Tehran who voted for Mr. Hemmati, the candidate’s lack of political experience was an advantage. “He said he has come to turn the old structures upside down. It’s not an easy job,” Mr. Shojaee said. “But I support the aspiration. It can at least open a crack of hope for bigger changes.”

The main hurdle for Mr. Hemmati, a technocrat with little constituency, is to persuade people to come out and vote. A high turnout has traditionally benefited reformists and moderates, as their voters are more likely to boycott elections in protest against how the country is run.

In the latest poll by the Iranian Students Polling Agency before Election Day, 44% of Iranians planned to vote, a historic low, of whom 64% said they would cast their ballot for Mr. Raisi. Mr. Hemmati polled at roughly 4%.

Mr. Hemmati appeared to have some success with Iranians who in the last minute had a change of heart. Tahereh Aghaei, a 29-year-old employee in an insurance company, said she had decided on election day to back Mr. Hemmati due to his economic policies and liberal views of social freedoms.

Supporters of Mr. Hemmati during a street rally in Tehran.

Supporters of Mr. Hemmati during a street rally in Tehran.

“I didn’t want to vote initially,” she said. “But in the past few days, as we approached Friday, I started getting worried. I thought I should play a part and chose Mr. Hemmati.”

The new president faces immediate challenges on the domestic and international fronts.

He and his government would need to take steps to boost the economy while keeping a check on the Covid-19 pandemic. Growth has stuttered in recent years, constrained by U.S. sanctions, while unemployment is high and the local currency has plummeted in value. The economic crisis has pushed more families into poverty. It has driven Iranians to protest in the streets, where they have been met with brutal force by security forces.

He would also have to contend with more tensions in the region. Iran has accused Israel of conducting attacks on its nuclear facilities and the killing of a top nuclear scientist last year. Israel, which opposes the nuclear accord, has refused to comment on the allegations.

Sogol, a 36-year-old homemaker and mother of four who voted for Mr. Raisi, said she trusted the cleric because of his management of the large Astan Quds Razavi charity foundation in Mashhad, and his prosecution of allegedly corrupt officials, including the brother of Mr. Rouhani.

“When he says he will do something, he will do it,” she said. “His ethics will become a model for society.”

Mr. Rouhani’s initial path to power back in 2013 should give Mr. Hemmati reason for optimism. One week before the election that year, Mr. Rouhani was also polling in single digits. He later won a landslide victory with over 50% of the vote by appealing to the middle ground.

Following news that the U.S. is willing to resume nuclear talks with Iran in coming weeks, WSJ’s Gerald F. Seib explains one tactic that could jumpstart diplomacy between the two countries. Photo illustration: Laura Kammermann The Wall Street Journal Interactive Edition

Write to Sune Engel Rasmussen at sune.rasmussen@wsj.com