Updated

Iran's top leader gave a salty rebuke Friday to U.S. questions over the openness of the presidential contest in the Islamic Republic, telling Washington "the hell with you" after casting his ballot in a race widely criticized in the West as rigged in favor of Tehran's ruling system.

The vote — bringing an end to the eight-year era of the combative President Mahmoud Ahmadinejad — has taken unexpected turns in the past days as reform-minded Iranians surged behind the lone moderate left on the six-candidate ballot.

A victory by former nuclear negotiator Hasan Rowhani would be seen as a small setback for Iran's Islamic establishment, but not the type of overwhelming challenge posed four years ago by the reformist Green Movement, which was brutally crushed after mass protests claiming Ahmadinejad's 2009 re-election was the result of systematic fraud in the vote counting.

If no candidate wins an outright majority, a runoff pitting the two top finishers would take place June 21, so even a strong showing by Rowhani in Friday's voting could be overturned.

Rowhani's backers, such as former President Akbar Hashemi Rafsanjani — who was blocked from running by Iran's ruling system — have urged reformists and others to cast ballots and abandon plans to boycott the election in protest over years of arrests and pressure.

Iran's security networks now appear to have blanket control, ranging from swift crackdowns on any public dissent to cybercops blocking opposition Internet websites and social media. Yet other cracks are evident.

Western sanctions over Iran's nuclear program have pummeled the economy by shrinking vital oil sales and leaving the country isolated from international banking systems. New U.S. measures taking effect July 1 further target the country's currency, the rial, which has lost half its foreign exchange value in the past year, driving prices of food and consumer goods sharply higher.

Such concerns could have a direct effect on the outcome of the election. Tehran's mayor, Mohammad Bagher Qalibaf, is widely viewed as a capable fiscal manager and could draw in votes, since economic affairs are among the direct responsibilities of Iran's president.

Other key issues, such as the nuclear program, defense and foreign relations, are all fully controlled by the Khamenei, his inner circle and its protectors, led by the powerful Revolutionary Guard. The other candidates permitted on the ballot by election overseers are seen as hard-line loyalists, including current nuclear negotiator Saeed Jalili and Khamenei adviser Ali Akbar Velayati.

Such insiders in the presidency would give Iran's leadership a seamless front with significant challenges ahead, such as the possible resumption of nuclear talks with the U.S. and other world powers and the increasing showdown in Syria between rebels and the Iranian-backed regime of Bashar Assad. On Thursday, the White House said it would begin sending arms to Syrian rebel fighters after intelligence officials concluded Assad's forces used chemical weapons.

Recent comments by Khamenei were interpreted as support for Jalili, whose reputation is further enhanced by a battlefield injury during the 1980-88 war with then U.S.-backed Iraq that cost him the lower part of his right leg. Khamenei, however, has not publicly endorsed a successor for Ahmadinejad, who had a spectacular falling out with the theocracy over his attempts to challenge Khamenei's near-absolute powers.

Khamenei remained mum on his choice even as he cast his ballot early Friday. Instead, he blasted the U.S. for its repeated criticism of Iran's clampdowns on the opposition and the rejection of Rafsanjani and other moderate voices from the ballot.

"Recently I have heard that a U.S. security official has said they do not accept this election," Khamenei was quoted by state TV after casting his vote. "OK, the hell with you."

In Washington on Thursday, State Department spokeswoman Jen Psaki said that while the U.S. does not think the Iranian election process is transparent, it is not discouraging the Iranian people from voting.

"We certainly encourage them to," Psaki said. "But certainly the history here and what happened just four years ago gives all of us pause."

After voting, Rafsanjani said he hoped the election would lead to "national unity, a requirement for success against any domestic and foreign risks."

But there also are clear chances that the election could leave Iran further divided. Rowhani's rapid rise from longshot to reformist hopeful — aided by endorsements from artists and activists — has shown the resilience of Iran's opposition despite relentless crackdowns. A defeat could leave them even more embittered and alienated.

At final rallies, Rowhani's supporters waved his campaign's signature purple — a clear nod to the single-color identity of the now-crushed Green Movement and its leader, Mir Hossein Mousavi, who has been under house arrest for more than two years. On Wednesday, the last day of campaigning, thousands of supporters welcomed Rowhani in the northeastern city of Mashhad yelling: "Long live reforms."

Some Rowhani backers also have used the campaign events to chant for the release of Mousavi and other political prisoners, including former parliament speaker Mahdi Karroubi, leading to some arrests and scuffles with police.

Rowhani is far from a radical outsider, though. He led the influential Supreme National Security Council and was given the highly sensitive nuclear envoy role in 2003, a year after Iran's 20-year-old atomic program was revealed.

But he is believed to favor a less confrontational approach with the West and would give a forum for now-sidelined officials such as Rafsanjani and former President Mohammad Khatami, whose reformist terms from 1997-2005 opened unprecedented social and political freedoms that have since been largely rolled back.

It was unclear how much the boycott calls by reformists could cut into the turnout among Iran's estimated 50 million voters, which was reported at 85 percent four years ago. In Tehran, lines were seen at various polling stations. State TV also showed video of voting queues in various cities.

Journalists were under wide-ranging restrictions limiting movement around the country. Iran does not permit outside election observers.

Ali Akbar Nategh Nouri, a close adviser to Khamenei, predicted there would be no need for a runoff round next Friday. But Iran's interior minister, Mostafa Mohammad Najjar, dismissed "any speculation before ending the vote counting" by his office. Results are expected early Saturday.

Outside Iran, votes were casts by the country's huge diaspora including Dubai, London and points across the United States.