ISTANBUL (AP) — Ekrem Imamoglu, the opposition candidate who won an Istanbul mayoral election that was voided weeks later, retook office in Turkey's largest city following his repeat win, a stunning victory he called a step toward repairing a damaged democracy.

Cheered on by supporters of the opposition Republican People's Party, Imamoglu returned to Istanbul City Hall to take up the seat he held for 18 days before Turkey's top election board nullified the first election for mayor and ordered a rerun.

"The people of Istanbul have confirmed their attachment to the republic and to democracy," Imamoglu told the jubilant, flag-waving crowd. "This confirmation has shown the world that Turkey isn't any ordinary Middle Eastern country. The belief in democracy runs deep in Turkey's veins."

Imamoglu won the first vote on March 31 by a narrow margin. Turkish President Recep Tayyip Erdogan's governing party challenged the results, and recounts of ballots from some Istanbul districts went on for weeks before Imamoglu was inaugurated as mayor.

The electoral council eventually granted a request from the president's party to annul the election. The decision aroused concerns of a possibly deliberate undermining of democracy in Turkey, where Erdogan is accused of increasing authoritarianism.

In a rebuke to the ruling party, voters returned Imamoglu to the mayor's office by a much bigger margin. He received 54.21% of the vote — 806,000 votes more than the governing Justice and Development Party's candidate, former Prime Minister Binali Yildirim.

In his speech — interrupted by chants of "Mayor Ekrem" and his campaign slogan "everything will be beautiful" — Imamoglu promised to end what he described as the "squandering" of the city's public funds by the governing party.

"The squandering will end, the belt-tightening will start. Istanbul's 16 million (people) will share the city's blessings," he said.

Earlier, authorities at Istanbul's main court presented Imamoglu with a framed certificate confirming his mandate to rule over Turkey's largest city and commercial hub for the next five years. Istanbul's governor — the interim mayor — later handed over the municipality's official seal to Imamoglu in a televised ceremony.

Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.