Polling ended on Sunday for Turkey's rerun local elections to choose a new mayor for Istanbul with the eyes of the nation on the results.

Voting started at 8 a.m local time (0500 GMT) and ended at 5 p.m. local time (1400 GMT) in 31,342 ballot boxes across 39 districts of Istanbul.

Ekrem Imamoğlu, candidate of the opposition Republican People's Party (CHP), and Binali Yıldırım of the ruling Justice and Development Party (AK Party), will vie to run the metropolitan municipality of Turkey's most populous city after a previous vote on March 31 was annulled by the country's top election council last month.

Interior Minister Süleyman Soylu and his wife Hamide Soylu were early birds, casting their votes at Dobruca Middle School in Istanbul's Gaziosmanpaşa district soon after polling stations opened.

Around an hour later than expected at 11:30 a.m., Yıldırım and his wife Semiha came to Istanbul's Tuzla district to cast their ballots. One of Yıldırım's grandchildren posted the envelope into the ballot box for him.

Speaking to reporters after voting, Yıldırım said it was time to leave all resentments behind, and it was voters' turn to speak.

His rival Imamoğlu cast his vote in Istanbul's Beylikdüzü district about an hour later.

"Our people will make the best decision today for our democracy, for Istanbul and for legitimacy of all elections in our country in the future," he said in front of the Haldun Taner elementary school.

Meanwhile, President Recep Tayyip Erdoğan and first lady Emine Erdoğan voted in Istanbul's Üsküdar district.

They voted at the Saffet Cebi middle school, along with their daughter Esra and son-in-law Berat Albayrak, who is the treasury and finance minister.

The president said he was expecting a high turnout and would stay in Istanbul to follow the results.

"I think voters will make the best decision for Istanbul. Good luck with it," he said.

Millions of Turkish voters cast their votes nationwide on March 31 in local elections to choose mayors, city council members, mukhtars (neighborhood officials), and members of elder councils for the next five years.

On March 31, the turnout was 83.88%, 6 percentage points lower than the previous local elections of March 30, 2014.

In Istanbul, Imamoğlu received 48.8% of the vote, whereas Yıldırım got 48.55%, according to official figures from the Supreme Election Council (YSK).

AK Party won 24 district municipalities across the province, while the CHP won 14.

The results in March were canceled after AK Party and its coalition partner, the Nationalist Movement Party (MHP), appealed to the YSK, citing irregularities and contradictions with legal measures, leading to the annulment of Imamoğlu's mayoral certificate.

YSK chief Sadi Güven said all eligible voters who cast their ballots in the March 31 poll would be able to do so again in a re-do vote for Istanbul's metropolitan mayor.

However, 44,852 voters were removed from the electoral lists due to conviction, military service or death.

The YSK announced the total number of voters would be 10,560,963 for the June 23 elections.

On the March 31 elections, voters chose from among 32 candidates — 24 of them independent — on the ballot.

This time, there will be only 21 candidates, including nominees from the AK Party, the CHP, the Felicity (Saadet) Party and the Patriotic (Vatan) Party along with 17 independent hopefuls.

Why the re-do of elections?

The YSK ruled in favor of a rerun, with seven votes in favor and four against.

Some 30,281 votes in 108 ballot boxes were declared invalid due to vote-counting sheets being unsigned or absent altogether, the country's Supreme Election Council (YSK) said in a statement.

Also, polling clerks who were not civil servants served in 754 polling centers in the March 31 mayoral elections in Istanbul.

The council said this practice was unprecedented and influenced the difference between the ruling and opposition alliances — down to 13,729 ballots — and therefore raised questions on the validity of results.

Provincial election board chairman suffers heart spasm

Meanwhile, Judge Ziya Bülent Öner, the chairman of the provincial election board in Istanbul, suffered a heart spasm on late Saturday and was transferred to a hospital.

He underwent angiography in a private hospital and was placed under observation.

Öner was appointed to the post on May 12 after former head of the board, Judge Müberra Gürdal, retired following the March 31 local elections.

Judge Fatma Nilgün Uçar was appointed as the chairman of the board by the YSK.