ISTANBUL — President Recep Tayyip Erdogan of Turkey was confronting recriminations within his governing party and the wider circle of his supporters on Monday as the scale of the defeat of his candidate in the Istanbul mayoral race became clear.
The opposition candidate, Ekrem Imamoglu, emerged as the landslide winner of the mayoral election redo against Mr. Erdogan’s candidate, Binali Yildirim, according to preliminary results announced on Monday by Sadi Guven, the head of the High Election Council, confirming a significant defeat for the governing party.
Mr. Erdogan will now have his hands full in containing the fallout from the electoral defeat, the biggest of his political career, which came after his disastrous decision to push for a rerun of the mayoral election following Mr. Imamoglu’s victory in the first vote, in March.
The loss was a stinging one for Mr. Erdogan. Istanbul is his hometown, and his Justice and Development Party, or A.K.P., has dominated the city for 25 years, but anger over his decision to pursue a new vote and frustration over a weakening economy took their toll, even as he has sought to crack down on the opposition.
“Earthquake at the ballot box,” ran the front-page headline of Karar newspaper, which was founded by three years ago by journalists who had once been close to the A.K.P. government.
[For President Erdogan, the bill for Turkey’s debt-fueled growth is coming due.]
In the election, held on Sunday, Mr. Imamoglu won with 54 percent of the vote, compared with 45 percent for his opponent, Mr. Guven said. The margin of victory for Mr. Imamoglu was larger than in the March election — he won by over 800,000 votes, compared with a slim, 13,000-vote victory in the first ballot — as was turnout, up one percentage point, at 84 percent.
The official results will be announced after a period for any complaints to be submitted and examined, but for now, the margin of victory was taken by commentators and politicians on all sides as a sign of voter outrage at the second vote.
“Slap of the people,” Evrensel, a leftist newspaper that is frequently critical of Mr. Erdogan, announced on its front page. “Istanbul made its choice,” ran the headlines in three main pro-government newspapers.
Complaints had already been building within Mr. Erdogan’s party after its loss in the March election and the subsequent cancellation of that vote.
Political analysts said Mr. Erdogan was likely to take a lower profile at home in the immediate aftermath of the defeat.
“The big question is: Will he ultimately stick to the ultranationalist alliance and continue the paranoid security state or reverse course and attempt at reform?” said Asli Aydintasbas, a senior fellow with the European Council on Foreign Relations.
The largest challenge for Mr. Erdogan is a movement led by a former A.K.P. president, Abdullah Gul, and a former finance minister, Ali Babacan, to form a breakaway party. Both men support many of the ideals of the A.K.P., notably conservative pro-market policies with social support for the party’s lower-income political base.
Mr. Erdogan is likely to seek some changes, in part to weaken any challenge from the breakaway group, but that could destabilize his alliance with Devlet Bahceli and the Nationalist Movement Party, which he has relies on to secure the presidency and a majority in Parliament.
The Istanbul mayor’s race may seem relatively unimportant in the context of a national leader, but the stakes — and the risks — for Mr. Erdogan going forward are high, because his party has relied on financing from supporters in the business world and companies that have benefited from municipal contracts.
Now, not only has Mr. Erdogan lost access to that source, but Mr. Imamoglu will have access to records that seem likely to detail potentially embarrassing cronyism and wasteful spending that have benefited the president’s supporters.
Mr. Imamoglu got a taste of it during the 17 days he spent in office before he was forced to step aside during the election rerun. In that time, he discovered that Istanbul, Turkey’s economic capital, had dozens of cars at the mayor’s disposal and millions budgeted for officials’ homes, even as the city was sinking into debt.
In addition, the Istanbul municipality paid millions of dollars to charitable foundations run by members of Mr. Erdogan’s family last year, Turkish newspapers have reported.
Pro-government columnists are already moving to divert the mood, writing in the morning newspapers that Mr. Erdogan would turn to foreign policy to enhance his image. That suggested that far from tempering his stance after such a defeat, the president may project a more combative attitude in discussions abroad.
The pro-government newspaper, Aksam, had Turkey’s dispute with the United States over its purchase of the Russian S400 missile system as its lead story, with a headline that read “S400s a matter of sovereignty.”
“Today the most common feeling among the people is the betrayal by their historical allies, the U.S., France, the U.K. and Germany,” Hakki Ocal wrote in the pro-government Daily Sabah. Picking up the campaign slogan of the new mayor, he wrote, “Turkey has risen up this beautiful morning, believing everything will be all right, and turns a watchful eye to its region.”
Mr. Erdogan is likely to proceed with his purchase of the Russian S400 missile system despite American objections, said Ms. Aydintasbas, in the hopes that President Trump will soften the blow by waiving sanctions or choosing the least harsh sanctions.
“Trump is the wild card in this equation, and he may end up giving the Turkish leader the compromise he seeks,” she said.
Within Europe, Mr. Erdogan — who has fired, purged and arrested tens of thousands of people since a failed coup in 2016 — would have to release some of the political prisoners being held in Turkey in order to improve relation, Ms. Aydintasbas said.
Business leaders have also advised Mr. Erdogan that the release of detained journalists and civil society activists would smooth ties the European Union, said Bahadir Kaleagasi, the secretary general of Tusiad, an association of Turkish industry and businesses, in a recent interview.
One of the most prominent political prisoners, Osman Kavala, a philanthropist who is often described as the George Soros of Turkey, went on trial Monday after 19 months in detention. He is accused of trying to overthrow the government for supporting the popular protests in Taksim Square in 2013.
One of the most strident voices in the presidential circle, the columnist Hilal Kaplan, signaled that the political fight for Turkey was by no means over.
The A.K.P. alliance may have lost Istanbul and several of Turkey’s biggest big cities to the opposition People’s Republican Party, or C.H.P., she reminded readers, but it won presidential and parliamentary elections last year and general municipal elections in March with 52 to 54 percent of the vote.
“Moving forward, we will watch the C.H.P. leadership trying to overcome the challenges of being in charge and governing with a multitude of partners,” she wrote. “We will also see how the A.K. Party will perform as Istanbul’s opposition party.”
Anger among A.K.P. members and former supporters of the party at the electoral disaster was evident on social media.
Kemal Ozturk, a former columnist for the pro-government Yeni Safak newspaper who is well-connected in government circles, said the self-interest of the circle around Mr. Erdogan had come back to hurt them.
“They did such vile things as they considered everything permissible for their small interests that they stained, they damaged a huge community’s religion, cause and faith,” he posted on Twitter. “This is the real thing we should be enraged about. Losing Istanbul is small in comparison to that.”
Mustafa Yeneroglu, an A.K.P. lawmaker, posted on Twitter that, “We lost the moral superiority.”
“We can again be the hope as we do sincere self-criticism,” he wrote. “For that, we should give up the past and the myths and look to the future and the dreams of the youth; focus on rationality, superiority of the law, separation of powers and fundamental rights.”