Whoever is chosen will have to cope with a cratering economy, regional strife and deep divisions and discord at home.
After a testy campaign that featured strong attacks on the government by virtually all the candidates over the economy, internet restrictions and harsh enforcement of the hijab law on women, Iran was holding elections on Friday to pick a president.
The vote comes at a perilous time for the country, with the incoming president facing a cascade of challenges, including discontent and divisions at home, an ailing economy and a volatile region that has taken Iran to the brink of war twice this year.
With the race coming down to a three-way battle between two conservative candidates and a reformist, many analysts predict that none of them will achieve the necessary 50 percent of the votes, necessitating a runoff on July 5 between the reformist candidate and the leading conservative.
That outcome may be avoided if one of the leading conservative candidates withdraws from the race, but in a bitter public feud, neither Gen. Mohammad Baqer Ghalibaf, a former commander in the Islamic Revolutionary Guards Corps and a pragmatic technocrat, nor Saeed Jalili, a hard-liner, has budged.
The polls opened at 8 a.m. Friday local time across the country, with closings typically extending well into the night. But Iranian elections are tightly controlled, with a committee of appointed clerics and jurists vetting all the candidates and the intimidation of opposition voices in the news media.
As a result, many Iranians are expected to sit out the vote, either as a protest or because they do not believe that meaningful change can come through the ballot box.
Four young women studying psychology at Tehran University who were buying makeup at the Tajrish Bazaar in northern Iran on Wednesday gave a flavor of that discontent. Although they were upset about conditions in Iran, they said, they were not planning to vote.
“We can’t do anything about the situation; we don’t have any hope except in ourselves,” said Sohgand, 19, who asked not to be further identified for fear of the authorities. “But we want to stay in Iran to make it better for our children.”
She was dressed in well-cut black pants and a fitted jacket, and had left her brown hair uncovered. But she also had a scarf draped around her shoulders in case an official told her to put it on. As for the rules requiring women to wear the hijab, she added simply, “We hate it.”
Trying to counter those attitudes, Iran’s top officials, from the supreme leader, Ayatollah Ali Khamenei, to senior commanders of the Revolutionary Guards Corps, have characterized voting as an act of defiance against Iran’s enemies and a validation of the Islamic Republic’s rule.
Ayatollah Khamenei cast his vote as the polls opened Friday morning in front of a bank of cameras and reporters at a ceremonial hall set up for the occasion in his official compound in central Tehran.
He used the occasion to urge Iranians to vote for the sake of the country, regardless of whom they supported, portraying it as a matter of civic duty that would bring the country “dignity and credit” in the eyes of the world.
“This is a big political exam for the nation and I know some people are suspicious and haven’t decided what to do,” he said, “but I can tell them it is important, it has many benefits, so why not?”
The government is predicting turnout of about 50 percent, higher than the most recent presidential and parliamentary elections but far lower than previous presidential elections, when more than 70 percent of the electorate participated.
Since Ayatollah Khamenei makes all the major state decisions in Iran, particularly in foreign and nuclear policy, the choice for those who do vote is more about the general political atmosphere of the country than any individual candidate.
With two of the original six candidates having dropped out, voters will choose from among Mr. Jalili, with his uncompromising views on domestic and foreign policy; Mr. Ghalibaf, who is the speaker of Parliament; the reformist candidate, Dr. Masoud Pezeshkian, a cardiologist and former health minister whose candidacy is something of a wild card; and Mostafa Pourmohammadi, a conservative cleric with past senior roles in intelligence who polls say will most likely get less than 1 percent of the vote.
The last days of the campaign have revealed strains between the top conservative candidates, Mr. Ghalibaf and Mr. Jalili, over who should drop out to consolidate the conservative vote and, they hope, avoid a runoff.
Little of that was in evidence at a rally on Wednesday in a sports stadium in Mr. Ghalibaf’s hometown, Mashhad, where he waved to a crowd of supporters holding the Iranian flag and chanting his name, videos of the event showed. “A strong Iran needs a powerful president; a strong Iran needs a president who works tirelessly,” said a cleric who introduced him.
But things were not going nearly so well for Mr. Jalili, who spoke at a rally in the same city that night. With the failure of previous negotiations on consolidating the vote, the commander in chief of the Quds Forces, Gen. Ismail Ghaani, flew to Mashhad on Wednesday night to force the two men into an emergency meeting, according to Iranian news reports and two officials familiar with the details of the meeting who asked not to be named so as to speak openly about the event.
General Ghaani said he wanted Mr. Jalili to withdraw, given the escalation of tensions in the region, with the Gaza war and a possible looming conflict between Hezbollah and Israel that could draw in Iran. In view of those issues, he said that Mr. Ghalibaf, with his military background and pragmatic outlook, was best suited to leading the government, the Iranians familiar with the meeting said.
In a remarkable public spat, with campaign officials on both sides attacking one another on social media, neither of the men relented.
The latest polling by Iranian state television — released on Wednesday, the last day of campaigning — showed Dr. Pezeshkian leading at 23.5 percent, Mr. Ghalibaf at 16.9 percent and Mr. Jalili at 16.3 percent, with 28.5 percent undecided and the remainder divided among the candidates, including those who had dropped out.
The televised debates, in which the candidates were surprisingly candid in slamming the status quo, showed that the economy, plagued with American sanctions and corruption and mismanagement, ranked as a top priority for voters and candidates, analysts said.
There is no fixing the economy without addressing foreign policy, they say, including the standoff with the United States over the nuclear program and concerns about Iran’s military engagement in the region through its network of militant proxy groups.
“Rather than radical change, the elections could produce smaller, albeit significant, shifts,” said Vali Nasr, a professor of international affairs and Middle East studies at the Johns Hopkins University School of Advanced International Studies in Washington. “Voices at the helm who want a different direction could nudge the Islamic Republic to back away from some of its positions.”
While apathy remains high in most urban areas, voters in provinces with significant ethnic populations of Azeri Turks and Kurds were expected to turn out in higher numbers for Dr. Pezeshkian. He himself is an Azeri Turk and served as the member of Parliament for the city of Tabriz, a major economic hub in the northwest province of East Azerbaijan. Dr. Pezeshkian has delivered campaign speeches in his native Turkish and Kurdish.
At a rally in Tabriz on Wednesday, the doctor received a folk hero’s welcome, with crowds packing a stadium and singing a Turkish nationalist song, according to videos and news reports. Ethnic and religious minorities are seldom represented in high office in Iran, so the candidacy of one for the presidency has generated interest and enthusiasm regionally, Azeri activists say.
Mr. Hakakpour said that while he and many other activists would not vote and did not consider Iran’s elections free or fair, he said that people who cast a ballot for Dr. Pezeshkian were hoping for small improvements in their lives and in their regions — like greater investments; reversing the drying of Lake Urmia, once a major body of water; and, most important, a greater sense of inclusion.