Turkey’s veteran leader Recep Tayyip Erdoğan on Monday led a hotly contested election to extend his rule into a third decade, defying polls to enter an expected run-off for the presidency with momentum on his side.

After a hard-fought campaign that had raised hopes of an opposition breakthrough, Erdoğan won 49.3 per cent of votes in the presidential race, well ahead of his main rival Kemal Kılıçdaroğlu on 45 per cent, according to preliminary results from state media.

With no candidate securing more than 50 per cent, the tally as it stands would send Erdoğan and Kılıçdaroğlu to a second round of voting on May 28. As well as building a lead of more than 2mn votes over Kılıçdaroğlu in the presidential race, Erdogan’s rightwing coalition appeared on course to win an outright majority in the Turkish parliamentary election, bolstering his position in any run-off.

Erdoğan’s performance overturned opinion polls that gave Kılıçdaroğlu a substantial lead in the final days of the bitterly fought campaign. The 74-year-old opposition leader had built a broad alliance of centrists, nationalists and conservative parties and had outside support from Turkey’s main Kurdish bloc in his bid to end what he calls Erdoğan’s “one-man rule”.

“Erdoğan massively exceeded expectations [and] Kılıçdaroğlu disappointed . . . The advantage looks to be with Erdoğan in the second round. He has momentum, and he will exploit divisions which will now likely appear in the opposition,” Timothy Ash, an emerging markets strategist at BlueBay Asset Management, said in a research note.

“Markets will be nervous between the first and second rounds, as Erdoğan’s economic policies just do not add up,” Ash wrote.

A painful economic crisis wrought by Erdoğan’s unconventional stewardship, in which he has suppressed interest rates despite inflation of more than 40 per cent, has eroded Turks’ savings and repulsed foreign investors.

Cost of living pressures, a devastating earthquake that killed more than 50,000 people in February and unhappiness with Erdoğan’s authoritarian style of rule had invigorated an opposition that believes it has its best chance yet to wrest control from Turkey’s longest-serving leader.

But Erdoğan again mobilised his support base with a focus on wedge issues, including the opposition’s tacit co-operation with a pro-Kurdish party that he accuses of terrorism links, as well as generous wage rises and other giveaways.

Erdoğan stopped short of declaring victory overnight in a speech from the balcony of his Justice and Development party (AKP) headquarters, the traditional venue he has used to celebrate most of his party’s dozen or so previous wins.

But the president appeared confident, singing a pop tune to thousands of flag-waving supporters and declaring: “We are already ahead of our closest rival [and] expect this figure to increase with official results.”

A simultaneous parliamentary election gave Erdoğan’s rightwing alliance a comfortable majority, which will help him retain his tight grip over the economy and other facets of Turkish life if he wins the run-off.

Kılıçdaroğlu, whose campaign slogan was to “finish it in the first round”, still struck a defiant tone early on Monday, saying: “We will absolutely win the second round . . . and bring democracy.”

A third-party candidate, the ultranationalist Sinan Oğan, received 5.2 per cent and was forced out of the race. Oğan said he was open to negotiations with both Erdoğan and Kılıçdaroğlu to deliver his voters in the second round. But he said any deal would require sidelining the main pro-Kurdish movement, which won seats in parliament as the Green Left party — a constituency Kılıçdaroğlu needs in any second challenge of Erdoğan.

Kılıçdaroğlu’s allies made repeated complaints on Sunday night about the reporting of the vote count, claiming state media was attempting to “deceive” the public by flattering Erdoğan’s position. But the opposition, which initially claimed it was significantly ahead of Erdoğan, toned down the objections as the vote count advanced.