Less than half a year after losing its hold on Turkey’s parliament, the country’s ruling Justice and Development Party regained a decisive majority Sunday in a dramatic snap election.

It marks a considerable political coup for President Recep Tayyip Erdogan, who has been at the helm of the country for 13 years and now looks likely to further entrench his rule.

In the buildup to Sunday’s election, a vast majority of pollsters and political analysts predicted a hung parliament and anticipated a tricky process of coalition-building that would have complicated Erdogan’s own designs on power.

But by nightfall on Sunday, Erdogan’s ruling party, also known by the Turkish abbreviation AKP, had taken almost 50 percent of the vote and was expected to form a single-party government once more. The result took many experts by surprise.

Supporters cheer Turkish President Recep Tayyip Erdogan (L) in front of a polling station in Istanbul. His party won a strong victory. AFP PHOTO / DIMITAR DILKOFF/AFP/Getty Images (Dimitar Dilkoff/AFP/Getty Images)

“This election was a referendum on Erdogan,” said Bulent Aliriza, a Turkey scholar at the Center for Strategic and International Studies in Washington. “He rolled the dice and won.”

The president’s gamble began when he balked at the outcome of a general election in June in which the AKP lost its parliamentary majority.

Prime Minister Ahmet Davu­toglu, the current leader of the party that Erdogan founded, was unable to form a coalition government, paving the way for a fresh round of elections that Erdogan hoped could restore the AKP’s position.

But in the absence of a stable government, the country’s faltering economy dipped further, with the Turkish lira now hovering just above an all-time low. Turkey also experienced an upsurge in violence over the summer. The decades-old civil war with Kurdish separatists flared back into life, and suspected Islamic State terrorists struck targets in Turkey, including Ankara, where a double bombing at a leftist rally killed 102 people in the worst terrorist attack in the country’s modern history.

Erdogan’s critics argued that the climate of tension and polarization surrounding Turkish politics was a direct consequence of his dema­gogic style. But Erdogan invoked the AKP’s single-party rule as the best guarantee of Turkey’s security and national interests.

“It has become apparent how important stability is to our nation. All of us should respect the attitude of the national will,” Erdogan told reporters Sunday after voting at a school in Istanbul’s leafy Kisikli neighborhood, on the Asian side of the Bosporus.

Judging by the election’s results, many voters heeded the message.

“It shows that the Turkish electorate cares more about stability and the economy, rather than rights, freedom of expression, and other things that should matter in a normal democracy,” said Suat Kiniklioglu, a columnist and former Turkish lawmaker.

Erdogan had wanted the earlier June election to deliver the AKP a supermajority in parliament that could allow him to overhaul the Turkish political system and win more executive powers as president.

In recent years, some of Erdogan’s opponents in the media have faced intimidation, censorship and even physical attack. He is frequently accused of being a would-be autocrat, paranoid and irrational, forever inveighing against foreign plots and threats.

In the run-up to Sunday’s election, there was a prevailing sense that Erdogan was a president lost in his own labyrinth. But he ended up outwitting Turkey’s opposition.

“I can’t recall how many articles I’ve read about the end of Erdogan,” said Ceren Kenar, a Turkish TV journalist and prominent commentator, referring to the international media’s skepticism of the Turkish leader. “Yet Erdogan has proved again that he’s a major player in Turkish politics.”

Erdogan allowed himself to bask in the victory.

“At the moment, one party has come to power in Turkey with around 50 percent of the vote,” he told reporters in Istanbul after morning prayers on Monday. “The entire world needs to respect this. I haven’t seen very much of such respect in the world.”

His gift for strategic calculation is compounded by a powerful personal magnetism.

“Erdogan is without a shadow of a doubt Turkey’s best politician,” Aliriza said. “He is almost Clintonlike in his ability to empathize, to make contact with [the] electorate.”

In the early hours of Monday morning, Davutoglu, the triumphant prime minister, ascended the balcony at AKP headquarters in Ankara before a jubilant crowd of supporters. He hailed Erdogan, the founder of the ruling party and a three-term prime minister between 2003 and 2014.

“The new Turkey will be built under the leadership of President Erdogan,” he said.

Some in the audience chanted “Allahu Akbar,” or “God is great.” The center-right AKP has the support of a staunchly religious nationalist base, cultivated by years of Erdogan’s rule.

“I’m in love with Erdogan,” said Nerve Yilmaz, a 22-year-old college student who attended a small AKP rally in the waterfront Istanbul district of Kadikoy on the eve of the election. She mentioned being able to wear her headscarf at school, something earlier generations of devout Muslim women could not do under Turkey’s state-sanctioned secularism, which marginalized many Turks who did not belong to its urban elites.

“If I ever saw him, I think I’d burst into tears,” said Yilmaz, who insisted that her support for the AKP was simply out of devotion to its most important leader.

Similar fervor was on display Sunday, when Erdogan’s motorcade pulled up at the Saffet Cebi school, where the president cast his ballot alongside his wife and daughter. Hundreds of supporters waited outside, chanting his name and declaring, “Turkey is proud of you.” Erdogan’s bodyguards distributed presents to children in the crowd.

Yet for all this admiration, Erdogan remains a figure as loathed as he is loved.

“Erdogan is a dictator and a thief,” said Nese Ceniz, a 57-year-old writer who voted in the trendy Cihangir neighborhood. “We shouldn’t have a one-man regime in Turkey.”

Ceniz supported the Peoples’ Democratic Party, or HDP, a leftist, pro-Kurdish party whose unprecedented success in June came at the AKP’s expense. But Sunday’s results indicated that Erdogan’s party had wooed back some HDP votes in the country’s Kurdish-majority southeast, an unexpected turnaround from the summer.

This was, in part, the result of the renewed conflict between the Turkish state and the Kurdistan Workers’ Party, or PKK, a separatist militant group considered to be a terrorist organization. Turkish authorities claim that PKK attacks have killed more than 150 security personnel since July, and the government launched an intense counter-
insurgency campaign, including airstrikes on PKK camps in northern Iraq. The low-level civil war, championed by Erdogan, won his party votes from right-wing nationalists as well as conservative Kurds, who perhaps saw in the AKP a better prospect for peace.

“Erdogan’s ‘strong man who can protect you’ strategy has worked,” said Soner Cagaptay, a Turkey expert at the Washington Institute for Near East Policy.

Turkey’s opposition parties will have to reckon with a status quo potentially dominated by Erdogan and the AKP for years to come — and haunted by their inability to unite as a solid anti-AKP bloc.

Experts think that with its new comfortable majority, the AKP might adopt a more conciliatory line. This could involve restarting peace talks with the Kurds.

“The mission has been accomplished from their sense — they have won the election,” Kiniklioglu said. “I could see that a reconciliation process could restart.”

Davutoglu cut a magnanimous figure on the balcony in Ankara. “There is no one beaten in this election. Turkey won, our democracy won,” he said.

Vildan Ay in Istanbul contributed to this report.