ANKARA, TURKIYE -- Early in his political career, a devastating earthquake and economic troubles helped propel Recep Tayyip Erdogan to power in Turkiye. Two decades later, similar circumstances are putting his leadership at risk.

The highly divisive and populist Erdogan is seeking a third consecutive term as president on May 14, after three stints as prime minister, which would extend his rule into a third decade. He already is Turkiye's longest-serving leader.

The presidential and parliamentary elections could be the most challenging yet for the 69-year-old Erdogan. Most opinion polls point to a slight lead by his opponent, Kemal Kilicdaroglu, who heads the secular, center-left Republican People's Party, or CHP. The outcome of the presidential race could well be determined in a runoff vote May 28.

Erdogan is facing a tough test in this election because of public outrage over rising inflation and his handling of the Feb. 6 earthquake in southern Turkiye that killed over 50,000 people, levelled cities and left millions without homes. His political adversaries say the government was slow to respond and that its failure to enforce building codes is to blame for the high death toll.

Some even point to government malfeasance after a 1999 earthquake in northwestern Turkiye near the city of Izmit that killed about 18,000 people, saying that taxes imposed from that disaster were misspent and worsened the effects of this year's quake.

The political party founded by Erdogan in 2001 came to power amid an economic crisis and the Izmit quake. His Justice and Development Party, or AKP, capitalized on public anger over government mishandling of the disaster, and Erdogan became prime minister in 2003 and has never relinquished leadership of the country.

Still, even with resentment directed toward Erdogan over his handling of the February quake and the economy, analysts caution against underestimating him, pointing to his enduring appeal among working- and middle-class religious voters who had long felt alienated by Turkiye's former secular and Western-leaning elites.

Erdogan's nationalist policies, often confrontational stance against the West and moves that have raised Islam's profile in the country continue to resonate among conservative supporters. They point to an economic boom in the first half of his rule that lifted many people out of poverty, adding that his past successes are proof of his ability to turn things around.

"There is an economic crisis in Turkiye, we can't deny it. And yes, this economic crisis has had a huge impact on us," said Sabit Celik, a 38-year-old shop owner selling cleaning products in Istanbul. "But still, I don't think anyone else (but Erdogan) can come and fix this."

"I think our salvation is through the (ruling party) again," he said.

Many also point to major infrastructure projects begun during his tenure -- highways, bridges, airports, hospitals, and low-income housing.

Erdogan himself has conceded that there were shortcomings in the early days of the February earthquake but insisted the situation was quickly brought under control.

Since then, he has focused his reelection campaign on reconstructing quake-stricken areas, promising to build 319,000 homes within the year. At rally after rally, he has touted past projects as proof that only his government can restore the region.

Erdogan has announced a series of spending measures to bring temporary relief to those hardest-hit by inflation, including raising minimum wages and pensions, enacting measures to allow some people to take early retirement, and providing assistance to consumers for electricity and natural gas.

He also has focused on the defence sector, boosting production of drones and fighter jets and building an amphibious landing vessel that the government describes as "the world's first drone carrier."

"While we were a country that could not even produce pins, an unmanned aerial plane flew above our skies the other day," said Mustafa Agaoglu, another Erdogan supporter in Istanbul. "We now have our warships, our aircraft carriers, our roads, our bridges, our city hospitals."

Erdogan has timed a host of openings to coincide with the election campaign. Last month, he presided at a ceremony marking the delivery of natural gas from recently discovered Black Sea reserves, offering free gas to households for a month. This week, he announced the discovery of a new oil reserve in the country's southeast, with a capacity of 100,000 barrels per day.

When he suffered a brief intestinal illness that sidelined him for a few days, he took part via video in an event marking the delivery of fuel to Turkiye's first nuclear power plant.

Then, on Sunday, he said Turkiye's intelligence teams had killed the leader of the Islamic State group in a special operation in northern Syria -- an announcement that seemed designed to bolster his image as a strong leader.

In the upcoming election, six parties have united behind his main opponent, Kilicdaroglu, despite their disparate political views. The coalition, known as the Nation Alliance, has vowed to reverse the democratic backsliding and crackdowns on free speech and dissent under Erdogan, seeking to scrap the powerful presidential system he introduced that concentrates vast authority in his hands.

As in previous years, Erdogan has waged a bitter campaign, lashing out at Kilicdaroglu and other opponents. He accused them of colluding with what he calls terrorists. This year, he has also tried to disparage the opposition by saying it supported "deviant" LGBTQ+ rights that he says threaten Turkiye's "sacred family structure."

On Monday, he portrayed the election as a "choice between two futures."

"Either we will elect those who take care of the family institution, which is the main pillar of society, or those who have the support of deviant minds that are hostile to the family," Erdogan said.

He has expanded his alliance with two nationalist parties to include two small Islamist parties that call for amendments to a law protecting women against violence, arguing it encourages divorce.

Opposition parties again are complaining of an uneven playing field during the campaign, accusing Erdogan of using state resources as well as his government's overwhelming control over the media.

Some also are questioning whether Erdogan would agree to a peaceful transfer of power should he lose. In 2019, Erdogan challenged the results of a local election in Istanbul after his ruling party lost the mayoral seat there, only to suffer an even more embarrassing defeat in a second balloting.

------

Mehmet Guzel in Istanbul contributed.