TEHRAN, June 18 (Reuters) - Millions of Iranians voted on Friday in a contest set to hand the presidency to a hardline judge who is subject to U.S. sanctions, though anger over economic hardship and curbs on freedoms mean many will heed calls for a boycott.

Senior officials appealed for a large turnout in an election widely seen as a referendum on their handling of the economy, including rising prices and unemployment and a collapse in the value of its currency.

"I urge everyone with any political view to vote," judiciary head Ebrahim Raisi, the front-runner in the contest, said after casting his ballot.

"Our people's grievances over shortcomings are real, but if it is the reason for not participating, then it is wrong."

While state television showed long queues at polling stations in several cities, the semi-official Fars news agency reported 22 million or 37% of voters had cast ballots by 7:30 p.m. (1500 GMT), citing its own reporter. The interior ministry said it could not confirm turnout figures.

State television said voting officially ended at 1930 GMT. However, the interior ministry said voting had been extended for two hours in some polling stations across the country to allow latecomers to cast ballots. read more

The final results are expected to be announced by mid-day on Saturday.

After voting in the capital Tehran, Supreme Leader Ayatollah Ali Khamenei urged Iranians follow suit, saying "each vote counts ... come and vote and choose your president".

Raisi, 60, is backed by security hawks in his bid to succeed Hassan Rouhani, a pragmatist prevented under the constitution from serving a third four-year term in the post, which runs the government day-to-day and reports to Khamenei.

Supported by the powerful Revolutionary Guards Corps, Raisi, a close Khamenei ally who vows to fight corruption, is under U.S. sanctions for alleged involvement in executions of political prisoners decades ago.