Turkish President Recep Tayyip Erdogan declared victory in a pivotal election Sunday, saying voters had “handed him” the presidency.

Speaking early Monday, Supreme Election Council head Sadi Guven said 97.7 percent of votes had been counted and declared Erdogan the winner, according to the Associated Press.

The election was one of the most consequential votes in years and saw a revitalized opposition unify to challenge the incumbent president, who has ruled Turkey for a decade and a half.

The victor will wield sweeping executive powers under a new presidential system, which curbs the authority of parliament and the judiciary and which critics say entrenches one-man rule.

Erdogan’s ruling party and its nationalist ally also appeared to secure a majority in the legislature, based on unofficial results published by both the state-run news agency and the opposition-linked Election Justice Platform, which was monitoring the count.

Still, Erdogan’s main challenger, Muharrem Ince, and his secular-left People’s Republican Party, or CHP, urged observers to stay at the country’s ballot boxes to ensure votes were counted fairly.

Ince was reported by pro-government media and the pro-opposition platform to have received roughly 30 percent of the vote, with the remaining ballots apparently cast for lesser-known candidates.

The state-run Anadolu Agency said the CHP-led alliance received 34 percent of the parliamentary vote, while Erdogan’s Justice and Development Party, or AKP, lost its majority. But together with its ally, the Nationalist Movement Party, which outperformed at the polls, it will maintain control of the parliament.

The pro-Kurdish Peoples’ Democratic Party, or HDP, also passed the 10 percent threshold to enter parliament, despite the imprisonment of its leader and presidential candidate, Selahattin Demirtas.

Videos allegedly showing voting irregularities and uncounted ballots circulated on social media Sunday, but the images could not be verified.

Erdogan’s supporters took to the streets in Istanbul and other cities in celebration Sunday night.

The votes for president and parliament were critical tests for Erdogan, 64, who sought reelection to another five-year term. But for the first time, he faced a formidable challenger in Ince, whose charisma and sharp criticism of the president gave him wide appeal. His election rallies drew millions in cities throughout the country.

Erdogan had called surprise snap elections in April, 19 months ahead of schedule, in a move that analysts said was intended to catch the opposition off guard.

On Sunday, prior to the polls closing, there were scattered reports of ballot-stuffing, largely in Turkey’s southeast, where tensions between the government and the ethnic Kurdish minority remain high.

The election council, responding to reports of vote-rigging, announced earlier in the day that it had “taken action” to prevent further fraud, but other officials played down the allegations. A report by the Anadolu Agency said 10 foreigners — including French, German and Italian nationals — had been arrested over alleged attempts to “interfere” in the elections, citing Interior Ministry officials. The report said they were not accredited to monitor the vote.

More than 55 million people were registered to vote, out of a population of 81 million, authorities said.

Under Erdogan, the government has presided over a far-reaching crackdown on dissidents, activists and the media, jailing journalists and opposition leaders, and shuttering independent news outlets. Since a coup attempt nearly two years ago, Erdogan has placed Turkey under a state of emergency, and observers say that has interfered with the integrity of the election.

One challenger, pro-Kurdish leader Demirtas, had run his campaign from a jail cell. He was arrested in November 2016 and held on terrorism charges. Other members of his party, HDP, also have been arrested or removed from government positions.

“There’s no justice, no freedom” in this country, said 35-year-old Habib Celebi, a textile worker and HDP voter in Istanbul, Turkey’s largest city.

“We want democracy,” he said. “How can I vote for Erdogan?”

Ince, 54, had condemned what he says are the excesses of the security state under Erdogan and pledged to end emergency rule if elected. His CHP party led the coalition to challenge Erdogan. It is the largest opposition party in parliament.

“If Erdogan wins, your phones will continue to be listened to. . . . Fear will continue to reign,” Ince told the crowd at a rally in Istanbul on Saturday, according to Reuters.

“If Ince wins,” he continued, “the courts will be independent.”

But even as Ince sought to woo working-class voters from Erdogan and his party, the president remained widely popular. His supporters point to Turkey’s economic development as evidence of his leadership. Turkey, they said, was languishing in economic doldrums before the AKP swept to power in 2002. Now, the country has roads, bridges, airports and hospitals.

“I remember a time when we had to wake up at 4 a.m. to go to the hospital because the lines were so long. I remember when we had to wait five days to get bread,” said 56-year-old Tuncay Tek, who said he voted for Erdogan and the AKP on Sunday.

“Erdogan is a godsend,” he said.

But not everyone was happy with the economy, which has seen high growth but also rising inflation. The Turkish lira tumbled in recent weeks and has lost 20 percent against the dollar this year. Foreign-exchange reserves are dwindling, and investors worry that the president wields outsize influence over the Central Bank.

“If Erdogan stays in power, the results will be catastrophic,” said Ayse Yildirim, 46, who said she voted for the HDP.

“The country is falling apart, we are in debt, there is a currency crisis,” she said. “I returned to Germany from Turkey 10 years ago. And this is the most important election I’ve participated in.”

At another polling station in Istanbul, Erdogan told journalists that Turkey was “staging a democratic revolution,” Reuters reported.

“With the presidential system, Turkey is seriously raising the bar, rising above the level of contemporary civilizations,” he said.