ISTANBUL -- Turkish President Recep Tayyip Erdogan hasn't lost many elections since the conservative party he co-founded took control of the government in 2002. But the party's rare defeat in Istanbul, Turkey's largest city, was a political and personal setback for the country's leader.

Opposition candidate Ekrem Imamoglu's win Sunday in a repeat vote for mayor broke the lock the president's Islamist-rooted party long held on Istanbul's top public office. On Monday, Turks speculated whether Erdogan's opponents finally have the ability to challenge his rule.

Imamoglu's supporters partied long into the night after he trounced Erdogan's hand-picked candidate, a former prime minister, 54% to 45% in a rerun of the city's March 31 mayoral election. The Islamic-leaning ruling party challenged the first vote over alleged irregularities, and Turkey's electoral board nullified the results.

The streets of Istanbul, where Erdogan's rise in Turkish politics started with his own election as mayor 25 years ago, became an impromptu caravan of cars honking horns with overjoyed passengers leaning out the windows as they cheered and waved Turkish flags.

Imamoglu's victory "is the most serious setback for Erdogan since his Justice and Development Party first took office in November 2002 and will further fuel the already growing sense amongst both his opponents and many members of his own party that his career is now in irreversible decline," Wolf Piccoli of the New York-based risk analysis firm Teneo Intelligence, said.

The landslide win electrified the secular party that has been spent nearly two decades in lacklustre opposition as Erdogan's strengthened his hold on power.

The vote count was officially ratified Monday. But Justice and Development Party candidate Binali Yildirim conceded within minutes after the first returns were announced. Tens of thousands of opposition supporters flocked to a square in an Istanbul suburb late Sunday to greet Imamoglu, chanting his campaign slogan, "Everything will be great!"

Erdogan's 1994 election as Istanbul's mayor shocked Turkey's secular elite. A poem he recited during his tenure resulted in a conviction for inciting religious hatred for which he served fours month in prison in 1999. He rose to national prominence a few years later following a financial crisis that wiped out much of the Turkish political establishment.

As president, he has presided over years of growth. However, Turkey's economy has been in-and-out of recession in the last year, and the country is burdened by high borrowing costs and sovereign downgrades.

Turkey's borrowing rates eased Monday after months of political uncertainty. The yield on its 10-year government bond eased to 15.3% after touching 20% in mid-May.

Can Selcuki, general manager of Istanbul Economy Research, a market research and data analytics company, thinks the recent downturn and election result in Istanbul are likely to increase pressure on Erdogan within his own party. Senior officials have publicly distanced themselves and are widely rumoured to be setting up two breakaway parties.

"I suspect that the result will speed those (preparations) up," Selcuki said. "If new parties are going to be formed by former AK Party leaders, they might actually grab some (lawmakers). The number they attract to their side is important because that could change the arithmetic in parliament."

The repeat election angered AKP dissenters but also heightened public anxiety over the president's style of leadership, which critics describe as increasingly authoritarian.

Istanbul pastry chef Banu Kirmizigul said she voted in the repeat election, after sitting out the one in March, because she was inspired by Imamoglu's campaign.

"I am really happy and my faith in this country has been restored," she said. "I saw that our people had awakened and I decided to wake up now, and I cast my vote. We (the opposition) got 800,000 more votes. We were successful and I am very happy."

A group of election monitors from the Council of Europe, a Strasbourg-France based organization aimed at holding member states accountable for human rights commitments, said Sunday's election was held "competently and in compliance with the applicable rules."

------

Ayse Wieting, Mehmet Guzel, and Bulut Emiroglu in Istanbul contributed to this report