ISTANBUL (AP) — Turkish President Recep Tayyip Erdoğan faced the biggest challenge to his 20-year tenure in power, as preliminary results showed he failed to win a majority victory for a third term in Sunday’s election.

A second round will take place on May 28 with his main rival, Kemal Kılıçdaroğlu, the joint candidate of an alliance of opposition parties. Sinan Oğan, who ran as an independent, ranked third.

Turkey’s state news agency Anadolu reported on Monday that Erdoğan got 49.35% of the vote, while Kılıçdaroğlu got 45%. Ogan had 5.22%, he said.

Erdoğan said that he welcomed a second round if that was the wish of the electorate.

He also expressed pride in what he said was a record turnout. «Turkey has shown once again that it is one of the world’s leading democracies,» he said at his party’s headquarters.

The runoff in the centenary year of the Republic of Turkey comes after some of the most disputed presidential and parliamentary elections in recent memory.

Outside of NATO member Turkey, the results will reverberate after it maintained close ties with Russia and blocked Sweden’s membership in the defense alliance. It remains to be seen what the results mean at the regional level, too, as Turkey’s influence grows among its neighbors and the Muslim world as a whole.

For around 5 million new voters who have never met any other leader, the election was a chance for change in a country where Erdogan’s AK Party has been in power since 2002. Erdogan, 69, became prime minister the following year and president in 2014.

More than 64 million people, including 3.4 million overseas voters, were eligible to vote and turnout, in a country where it is traditionally strong, was high.

Harun Armağan, a member of the AK Party’s Central Decision-Making Board, said on Sunday night that the results bode well for Erdogan.

“We can clearly see that it is a solid victory for President Erdoğan and the AK Party,” he said. «It is a night of victory for the millions of supporters of the AK Party in Turkey.»

Before the elections, the atmosphere was optimistic in Istanbul.

“I just voted and I’m waiting for the results,” said Banu Yilmaz, 60, a retired banker.

Zafer Özi, 81, a retired pharmacist, said: “We hope that this time something can change in our country. Because now I think people are more aware.»

Turkey is still reeling from the aftermath of two massive earthquakes in February, which devastated 11 southern provinces and killed tens of thousands of people.

Erdoğan’s government has been criticized for its response to the disaster, as well as lax implementation of building codes that worsened the misery.

A languishing economy, which critics have accused the government of mismanaging, and a sharp cost-of-living crisis also dominated the agenda, along with a backlash against millions of Syrian refugees, in the run-up to the vote.

Erdoğan increased salaries and pensions and subsidized electricity and gas bills in a bid to appeal to voters while leading a divisive campaign in which he accused the opposition of being «drunks» in cahoots with «terrorists.» He also attacked opponents for standing up for LGBTQ rights, which he said were a threat to traditional family values.

Kılıçdaroğlu, 74, who has led the secular, center-left Republican People’s Party (CHP) since 2010, vowed to reverse Erdogan’s policies and restore democracy.

A markedly different figure from Erdoğan, known for his bombastic speeches, he is soft-spoken and has built a reputation as a bridge builder. During the campaign, he recorded videos in his kitchen in an attempt to speak to voters.

His six-party National Alliance vowed to dismantle the narrowly voted presidential executive system in a 2017 referendum. Since then, Erdogan has centralized power in a 1,000-room palace on the outskirts of Ankara, and it is from there that Formulated Turkey’s policies on economic, security, internal and international affairs.

In addition to returning the country to parliamentary democracy, Kılıçdaroğlu and the alliance vowed to establish the independence of the judiciary and the central bank, institute checks and balances, and reverse democratic rollback and the crackdown on freedom of expression and dissent under Erdogan.

The alliance includes the nationalist Good Party, led by former Interior Minister Meral Akşener, and two parties that broke away from Erdogan’s AK Party and are led by former Prime Minister Ahmet Davutoğlu and former Finance Minister Ali Babacan.

Also running for president was Sinan Oğan, a former academic who is backed by an anti-immigrant nationalist party. Another candidate, center-left politician Muharrem İnce, dropped out of the race on Thursday after a significant drop in his ratings, but the country’s electoral board deemed his withdrawal invalid and votes for him will be counted.

Neyran Elden reported from Istanbul and Henry Austin from London.