Turkish President Recep Tayyip Erdogan declared victory Sunday in a historic runoff election that posed the toughest challenge of his two-decade rule.

“We will be ruling the country for the coming five years,” Erdogan told his cheering supporters from atop a bus in his home district in Istanbul. “God willing, we will be deserving of your trust.”

The 69-year-old leader faced down Turkey’s biggest economic crisis in generations and a united opposition to take a commanding lead.

The official Anadolu state news agency showed the Islamic-rooted leader ahead of his secular opposition rival Kemal Kılıçdaroğlu by four percentage points, with 97 percent of the vote counted.

A separate count published by the pro-opposition Anka news agency showed Erdogan leading by a similar margin.

NATO member Turkey’s longest-serving leader was tested like never in what was widely seen as the country’s most consequential election in its 100-year history as a post-Ottoman republic.

Kılıçdaroğlu cobbled together a powerful coalition that grouped Erdogan’s disenchanted former allies with secular nationalists and religious conservatives.

He pushed Erdogan into his first runoff on May 14 and narrowed the margin further in the second round.

Opposition supporters viewed it as a do-or-die chance to save Turkey from being turned into an autocracy by a man whose consolidation of power rivals that of Ottoman sultans.

The 74-year-old had always adhered to the firm nationalist principles of Mustafa Kemal Ataturk, the revered military commander who formed Turkey and Kılıçdaroğlu’s secular CHP party.

But these had played a secondary role to his promotion of socially liberal values practiced by younger voters and big-city residents.

Analysts questioned whether Kılıçdaroğlu’s gamble would work.

His informal alliance with a pro-Kurdish party that Erdogan portrays as the political wing of banned militants left him exposed to charges of working with “terrorists”.

And Kılıçdaroğlu’s courtship of Turkey’s hard right was hampered by the endorsement Erdogan received from an ultra-nationalist who finished third two weeks ago.

Erdogan is lionised by poorer and more rural swathes of Turkey’s fractured society because of his promotion of religious freedoms and modernisation of once-dilapidated cities in the Anatolian heartland.

But Erdogan has caused growing consternation across the Western world because of his crackdowns on dissent and pursuit of a muscular foreign policy.

He launched military incursions into Syria that infuriated European powers and put Turkish soldiers on the opposite side of Kurdish forces supported by the United States.

His personal relationship with Russian President Vladimir Putin has also survived the Kremlin’s war on Ukraine.

Turkey’s troubled economy is benefiting from a crucial deferment of payment on Russian energy imports that helped Erdogan spend lavishly on campaign pledges this year.

Erdogan also delayed Finland’s membership of NATO and is still refusing to let Sweden join the US-led defence bloc.

Turkey’s unravelling economy will pose the most immediate test for whoever wins the vote.

Erdogan went through a series of central bankers to find one who would enact his wish to slash interest rates at all costs in 2021, flouting conventional economics in the belief that lower rates can cure chronically high inflation.

Turkey’s currency soon entered free fall and the annual inflation rate touched 85 percent last year.

Erdogan has promised to continue these policies and rejected predictions of economic peril from analysts.

Turkey burned through tens of billions of dollars trying to support the lira from politically sensitive falls ahead of the vote.

Many analysts say Turkey must now hike interest rates or abandon its attempts to support the lira.

“The day of reckoning for Turkey’s economy and financial markets may now just be around the corner,” analysts at Capital Economics warned.

Maïssa Ben Fares, avec AFP