ISTANBUL — Turkish President Recep Tayyip Erdogan further solidified his grip on power Sunday as Turkey's electoral board said he won the presidential election with 97.7 percent of votes counted.

Earlier, unofficial results published by the state news agency showed the 64-year-old leader winning more than 50 percent of the vote — enough to avoid a runoff. However, his closest challenger, Muharrem Ince, refused to concede defeat while results from the national election authority were pending.

The presidential election and a parliamentary election also held Sunday took place more than a year early. They were the last step needed to complete Turkey’s transition from a parliamentary system of government to a strong presidential system, a change voters approved last year.

“The nation has entrusted to me the responsibility of the presidency and the executive duty,” Erdogan said in televised remarks from Istanbul after a near-complete vote count published by the state-run Anadolu news agency had him receiving 52.5 percent of the vote and the secular Ince, his nearest challenger, 30.7 percent.

Cheering Erdogan supporters waving Turkish flags gathered outside the president’s official residence in Istanbul, chanting, “Here’s the president, here’s the commander.”

Thousands of jubilant supporters of the pro-Kurdish Peoples’ Democratic Party, or HDP, also spilled into the streets of the predominantly Kurdish southeastern city of Diyarbakir after unofficial results from Anadolu showed the party surpassing the 10 percent threshold needed to enter parliament and garnering 11.5 percent of the vote.

The HDP’s performance was a particular success since presidential candidate Selahattin Demirtas, eight more of its lawmakers and thousands of party members campaigned from jails and prisons. HDP says more than 350 of its election workers have been detained since April 28.

The imprisoned Demirtas, who has been jailed pending trial on terrorism-related charges he has called trumped-up and politically motivated, was in third place in the presidential race with 8.3 percent of the vote, according to Anadolu.

Revelers waved HDP flags and blared car horns.

Erdogan insisted the expanded powers of the Turkish presidency will bring prosperity and stability to the country, especially after a failed military coup attempt in 2016.

A state of emergency imposed after the coup remains in place.

Some 50,000 people have been arrested and 110,000 civil servants have been fired under the emergency.

The president’s critics have warned that Erdogan’s re-election would cement his grip on power.