Erdogan has steered the nation of 85 million through one of its most transformative and divisive eras

Istanbul (AFP) - Turkish polling stations closed Sunday in a knife-edge election that could end President Recep Tayyip Erdogan’s two-decade grip on power and put the mostly Muslim nation on a more secular course.

Turnout was expected to be huge in what has effectively become a referendum on Turkey’s longest-serving leader and his Islamic-rooted party.

It is the toughest of more than a dozen votes the 69-year-old leader has confronted – one that polls hint he might lose.

“We need change, we’ve had enough,” farmer Mehmet Topaloglu told AFP after voting amid the ruins left by a deadly February earthquake that razed the ancient city of Antakya and other parts of the southeast.

Erdogan has steered the nation of 85 million through one of its most transformative and divisive eras in the post-Ottoman state’s 100-year history.

Turkey has grown into a military and geopolitical heavyweight that plays roles in conflicts from Syria to Ukraine.

The NATO member’s footprint in both Europe and the Middle East makes the election’s outcome as critical for Washington and Brussels as it is for Damascus and Moscow.

Erdogan is lionised across swathes of conservative Turkey that witnessed a development boom during his rule.

Turnout was heavy across Turkey, including in the quake-ravaged city of Antakya

More religious voters are also grateful for his decision to lift secular-era restrictions on headscarves and introduce more Islamic schools.

“My hope to God is that after the counting concludes this evening, the outcome is good for the future of our country, for Turkish democracy,” Erdogan said after casting his ballot in Istanbul.

- ‘We all miss democracy’ -

Erdogan’s first decade of economic revival and warming relations with Europe was followed by a second one filled with social and political turmoil.

He responded to a failed 2016 coup attempt with sweeping purges that sent chills through Turkish society and made him an increasingly uncomfortable partner for the West.

Opposition leader Kemal Kilicdaroglu pledged to restore democracy after casting his ballot

The emergence of Kemal Kilicdaroglu and his six-party opposition alliance – a group that forms the type of broad-based coalition that Erdogan excelled at forging throughout his career – gives foreign allies and Turkish voters a clear alternative.

Polls suggest the 74-year-old secular leader is within touching distance of breaking the 50-percent threshold needed to win in the first round.

A runoff on May 28 could give Erdogan time to regroup and reframe the debate.

But he would still be hounded by Turkey’s most dire economic crisis of his time in power, and disquiet over his government’s stuttering response to the earthquake that claimed more than 50,000 lives.

“We all missed democracy,” Kilicdaroglu said after voting in the capital Ankara. “You will see, God willing, spring will come to this country.”

- ‘Can’t see my future’ -

Polls show Kilicdaroglu winning the youth vote – nearly 10 percent of the electorate – by a two-to-one margin.

“I can’t see my future,” university student Kivanc Dal told AFP in Istanbul on the eve of the vote.

Erdogan “can build as many tanks and weapons as he wants, but I have no respect for that as long as there is no penny in my pocket”.

But nursery schoolteacher Deniz Aydemir said Erdogan would get her vote because of the economic and social progress Turkey made after half a century of corruption-riddled secular rule.

The 46-year-old also questioned how a country could be ruled by a coalition of six parties – a favourite attack line of Erdogan during the campaign.

Turnout in Turkey's biggest election in generations is expected to approach 90 percent

“Yes, there are high prices… but at least there is prosperity,” she said.

Erdogan’s campaign became increasingly tailored to his core supporters as election day neared.

He branded the opposition a “pro-LGBT” lobby that took orders from outlawed Kurdish militants and was bankrolled by the West.

Erdogan’s ministers and pro-government media referred darkly to a Western “political coup” plot.

The opposition began to worry that Erdogan was plotting how to hold on to power at any cost.

Erdogan bristled when asked on Friday night television if he would agree to leave if he lost.

“This is a very silly question,” Erdogan fumed. “We would do what democracy requires.”

- Heavy turnout -

High turnout among the country’s 64 million registered voters is widely expected.

Opposition figures said some ballot boxes in Istanbul were already full by mid-afternoon Sunday.

The last national election saw Erdogan win 52.5 percent on a turnout of more than 86 percent.

Turkey has no exit polls but tends to count ballots quickly.

Turkey suffered an economic meltdown in the second decade of Recep Tayyip Erdogan's rule

Polling stations close at 5:00 pm (1400 GMT) and all reporting restrictions are lifted four hours later. The first partial results are often published before then.

Voters will also select a new 600-seat parliament.

Polls suggest that Erdogan’s right-wing alliance is edging out the opposition bloc in the parliamentary ballot.

But the opposition would win a majority if it secured support from a new leftist alliance that represents the Kurdish vote.