ANKARA, Turkey — Turkish voters gave President Recep Tayyip Erdogan a decisive victory in national elections on Sunday, lengthening his 15-year grip on power and granting him vastly expanded authority over the legislature and judiciary.
The election was the first to be held since Turkish voters narrowly approved a referendum last year to give the president — once a largely ceremonial role — sweeping executive powers. Mr. Erdogan will also have a pliant Parliament, with his conservative party and its allies having won about 53 percent of the vote in legislative elections on Sunday.
Mr. Erdogan has overseen a crackdown on lawyers, judges, civil servants and journalists under a state of emergency declared after a failed coup two years ago. His critics had portrayed Sunday’s election as their last chance to prevent Turkey from becoming an authoritarian state.
The victory has potentially grave consequences for cooperation within NATO, security in Iraq and Syria, and control of immigration flows into Europe.
Turkey has continued to cooperate with its Western partners on counterterrorism efforts, but Mr. Erdogan has tested the NATO alliance by drawing closer to President Vladimir V. Putin of Russia, buying an advanced Russian missile defense system and planning a Russian-built nuclear reactor in Turkey.
As in other countries where strongmen have gained at the ballot box, many Turkish voters appeared to have accepted Mr. Erdogan’s argument that powerful centralized authority was essential to forge a strong state and guard against the threat of terrorism.
The results released by the official Anadolu news agency showed Mr. Erdogan with just under 53 percent of the vote, enough to spare him from a runoff against his leading challenger, Muharrem Ince, who won nearly 31 percent.
At 10:30 p.m., Mr. Erdogan, 64, gave a short televised speech to applauding supporters at the gates of Huber Pavilion, one of his residences in Istanbul.
“It seems the nation has entrusted me with the duty of the presidency, and to us a very big responsibility in the legislature,” Mr. Erdogan said. “Turkey has given a lesson of democracy with a turnout of close to 90 percent. I hope that some will not provoke to hide their own failure.”
Mr. Erdogan said he would travel to Ankara, the capital, to make his traditional victory speech from the balcony of his party headquarters.
Flag-waving crowds gathered after midnight at the party headquarters, waiting for him to appear. He finally emerged at 3 a.m. Monday.
Mr. Erdogan acknowledged that his own party had taken a hit in the campaign, but said the result was a vindication of his ability to deliver. “The winner is the politics of providing services,” he said. “The winner is the supremacy of the national will. The winner is Turkey, the Turkish nation. The winner is all the aggrieved people in our region, all the oppressed in the world.”
Opposition parties initially called his claim of victory premature, but after midnight, Bulent Tezcan, the vice chairman of Mr. Ince’s party, the Republican People’s Party, conceded defeat in a brief televised speech.
“Our citizens should not be provoked, whatever the result is,” he said, urging his supporters to continue their campaign for democracy through peaceful means.
The victory means Mr. Erdogan will almost certainly make good on his desire to become the country’s longest-ruling leader, surpassing Mustafa Kemal Ataturk, who founded the modern Turkish republic out of the ruins of the collapsed Ottoman Empire.
Under the new system brought in by last year’s referendum, Mr. Erdogan can run for a second term as president — and a third, if he were to call an early election — opening the possibility that he could stay in office until 2032.
In parliamentary races, Mr. Erdogan’s party placed first, with more than 42 percent of the vote, the Anadolu agency reported, enough to retain a majority in alliance with the Nationalist Movement Party, which received about 11 percent.
Defenders of Turkey’s multiparty democracy did receive some cause for hope: The H.D.P. party, a liberal democratic party that emphasizes minority rights and is led by an imprisoned Kurd, Selahattin Demirtas, surpassed the 10 percent threshold needed to enter Parliament.
The deputy head of the Supreme Election Board said five parties had passed the threshold.
Soner Cagaptay, a scholar and author who has called Mr. Erdogan a “new sultan” in the vein of the absolute rulers of the Ottoman Empire, said the new Parliament would be the most politically diverse in 35 years, with nearly every major political faction represented.
Support for Mr. Erdogan appeared to be similar to its level in last year’s constitutional referendum, “suggesting that polarization around his simultaneously adored and loathed persona continues to divide Turkey,” Mr. Cagaptay said.
Amanda Sloat, an Obama administration official who is a senior fellow at the Brookings Institution, said that “one of the country’s biggest challenges for the foreseeable future remains the deep polarization of Turkish society.”
She said Mr. Erdogan’s reliance on the Nationalist Movement Party for its majority “means foreign policy will likely remain influenced by nationalist considerations.”
But she said the hard-fought election showed that Turkish democracy was resilient.
“The opposition parties ran surprisingly strong, energetic and competitive campaigns,” Ms. Sloat said. “Parliament will be diverse, with the coalition system ensuring the representation of a wide range of parties — including the Kurds.”
The victory for Mr. Erdogan and his allies appeared to defy last-minute polls indicating that they were in danger. The final opinion poll conducted by the independent Metropoll suggested that Mr. Erdogan might suffer a double blow, being forced into a second round of voting for the presidency and losing control of Parliament.
The election was seen in large measure as a referendum on Mr. Erdogan’s rule, with many voters expressing concerns about what they say is his growing authoritarian streak and a struggling economy, which they blame on corruption and mismanagement.
The economy, once a strong point for Mr. Erdogan, has stumbled badly in the last year. Turkey has accumulated significant foreign debt, the Turkish lira has lost 20 percent of its value and direct foreign investment has plunged as investors have been scared off by the president’s increasingly belligerent and anti-Western tone.
The economic turmoil may make Mr. Erdogan more careful about picking fights with the West, but it could also spell growing unrest and political challenges at home against a newly energized and unified opposition.
Bekir Agirdir, founder of the polling firm Konda, predicted that Mr. Erdogan would struggle to rule the country: His constitutional changes to create an executive presidency in 2016 were approved narrowly, 51 percent to 49 percent.
“He cannot rule the remaining 49 percent,” Mr. Agirdir said in an interview before Sunday’s election. He suggested that Mr. Erdogan was bound to see a showdown eventually. “This is the rehearsal. The real election will be in two to three years’ time.”
Many in the opposition saw the campaign as a final chance to save democracy. “We are crossing the last bridge before it falls,” said Burcu Akcaru, a founder of the new Good Party. “Then we leave the country.”
Mr. Erdogan called the election two months ago — they had not been expected until November 2019 — in hopes of scoring a big win that he maintained would be a turning point for the country, allowing him to create a stronger, more powerful state.
When he came to power 15 years ago, Mr. Erdogan won wide support as a pro-European, moderate Islamist who supported democracy and economic liberalization. But over the years the earlier philosophy was replaced by a more personal and dictatorial rule, particularly after the failed coup in July 2016. Along the way, he either abandoned or alienated many of his allies.
The new presidential system will codify the executive powers Mr. Erdogan has already been exercising under the state of emergency. Under the new system, the office of prime minister, which Mr. Erdogan held from 2003 to 2014, will be abolished. The cabinet will be composed of presidential appointees rather than elected lawmakers. And Parliament’s powers are reduced, including oversight of the budget.
Mr. Erdogan has imprisoned many of his critics, including thousands of Kurdish politicians and activists, members of civil society organizations, and Islamists accused of being followers of Fethullah Gulen, the cleric whom Turkish leaders accuse of organizing the coup attempt.
Devlet Bahceli, the leader of the Nationalist Movement Party, whose result on Sunday ensures the alliance’s parliamentary majority for Mr. Erdogan, said of the opposition: “They wanted to demolish us, they couldn’t manage; they wanted to ravage us, they failed.”
“Those who spell disasters hit the consciousness of Turkishness and fell apart,” he said.
The election’s losers must now figure out how to maintain a voice in an increasingly authoritarian nation.
Mr. Demirtas, the imprisoned Kurdish leader whose left-leaning minority-rights party won 11 percent of the vote, had urged Turks to vote against Mr. Erdogan and his allies, encouraging them to grab an opportunity before entering a “dark and obscure tunnel.”
“What you go through nowadays is only a trailer of the one-man regime. The most frightening part of the movie hasn’t even started yet,” he warned. “Everything will be arranged in accordance with the desire, pleasure and interests of one man. You will feel unable to breathe in a regime of fear and despair; you will feel like you are strangled.”