ANKARA (Reuters) - The charismatic 55-year-old mayor of Tehran seems a long-shot contender for Iran’s presidency, but could emerge as the main threat to President Hassan Rouhani if he beats other hardliners to emerge as the sole challenger in a second round.

Mohammad Baqer Qalibaf gestures in this undated handout photo provided by Tasnim News Agency on May 9, 2017. Tasnim News Agency/Handout via REUTERS

A chisel-jawed former Revolutionary Guards commander with an action man persona, an airline pilot’s license and a populist economic message, Baqer Qalibaf has so far defied the clerical establishment by refusing to drop out before the May 19 vote.

In the last election four years ago, Qalibaf very nearly made it to the run-off, despite placing a distant second to Rouhani with just 16.5 percent of the vote. Rouhani, who promised to reduce Iran’s international isolation and grant more freedoms at home, averted a second round by winning just over 50 percent.

This time around, establishment hardliners who want to unseat Rouhani are mainly placing their trust in Ebrahim Raisi, a jurist and cleric who studied at the feet of Supreme Leader Ayatollah Ali Khamenei.

They are not happy that the maverick Tehran mayor is standing again and splitting the anti-Rouhani vote.

“Qalibaf’s decision to remain in the race represents is a risk for him and the establishment,” said an official in Tehran, who asked not to be identified. “It will divide hardliners’ votes but it will also endanger his future career, as Qalibaf has ignored influential hardliners’ call to step down.”

Still, with his own record of drawing millions of voters, Qalibaf may be hoping he can beat Raisi in the first round to face Rouhani in the run-off a week later, which would force conservatives to rally behind him.

A similar path carried a previous populist Tehran mayor, Mahmoud Ahmadinejad, to the presidency in 2005, despite never quite dispelling the discomfort of the establishment.

From Qalibaf’s perspective, that could have been him: in 2005, he resigned his military posts to run for president and was seen as a strong contender, only to lose the crucial battle for second place in the final days when hardliners switched their allegiance to Ahmadinejad.

Ahmadinejad won 19.5 percent in the first round, good enough for second place, on his way to a surprising triumph against former President Akbar Hashemi Rafsanjani in the run-off. Qalibaf went on to win Ahamdinejad’s job as mayor of the capital, a post he has held ever since.

Qalibaf promotes his record as a pragmatic problem-solver, tackling the capital’s acute infrastructure problems and improving public transportation.

But Tehran’s chaotic and chronically snarled traffic, a corruption investigation in 2016 and the deaths of 50 firefighters in the collapse of a 17-storey building in January in Tehran have dented his popularity.

To civil rights activists and reformers he is also known for his previous role as a police chief who boasted of crushing protests and personally beating demonstrators.

He joined the elite Revolutionary Guards Corps (IRGC) at 19 and served as the commander of its air force from 1996. He still has a license to fly big airliners. He was appointed by Khamenei as Iran’s police chief after a bloody crackdown on students in Tehran ignited nationwide unrest in 1999.

In a two-hour audio recording, released by opposition websites and the U.S.-based International Campaign for Human Rights in Iran, Qalibaf is heard describing how he personally beat up protesters with batons.

He was among a group of IRGC commanders who in June 2003 sent a letter to then-president Mohammad Khatami, now seen as the father of Iran’s reform movement, effectively threatening a coup unless the president took firm control of protests.