Mahmoud Ahmadinejad flashes a V for Victory. (ATTA KENARE/AFP/Getty Images)

Well, he’s got this going for him: He knows the job.

As “stunned” onlookers watched, former Iranian president Mahmoud Ahmadinejad registered to run — once again — for president. In doing so, he defied the country’s supreme leader, who told him not to compete. (“I told him he should not participate in that matter,” Ayatollah Ali Khamenei said last year, according to his official website. It’s “not in his interest and that of the country.”)

The former president’s surprising decision to run adds even more uncertainty to the upcoming election. It’s widely seen as a referendum on the 2015 nuclear deal, in which Iran agreed to curb its uranium enrichment in exchange for international sanctions relief. A majority of Iranians support the deal, though many say that they’re disappointed by its limited economic impact.

That agreement was negotiated and signed by the current president, Hassan Rouhani, a moderate most people think will seek reelection. In 2013, Rouhani was elected in a landslide, thanks to the support of moderates and reformists. He had a background in nuclear negotiations, and swept into office preaching moderation and compromise. His priority was to end the country’s international isolation.

Rouhani has also pushed the country in a more moderate direction. He has said that he believes Iranians should have freedom to worship and he tweeted a photo of a female award-winning mathematician without her headscarf — though critics say he hasn’t made nearly enough progress. His reelection campaign revolves around this question: Should Iran continue to pursue a more international role in the world or should it remain isolated?

On that front, few politicians offer a starker contrast than Ahmadinejad. As president, he frequently attacked the West. He has called the Holocaust “a myth” and “a lie.” In 2005, he banned Western music from the radio. A year later, he blocked several major websites, including YouTube, in an effort to purge the country of Western influences.

His 2009 reelection was widely disputed, and it triggered some of the biggest protests in Iran since the 1979 revolution. Millions of people took to the streets to demand another vote. Instead, the supreme leader ruled that the result was valid; he ordered a major crackdown on dissent. Dozens of opposition activists were killed and thousands more were detained.

Publicly (and confusingly), Ahmadinejad has said that he only registered to run to support his former vice president, who’s also running for president. But he seems serious about the campaign. As the Guardian explains: “Despite Khamenei’s advice, Ahmadinejad had been building a campaign in the months leading to the official registration — visiting provinces, becoming more active online and speaking at more occasions. He recently joined Twitter.”

And he could be a serious contender. The high-profile politician remains popular in some corners of Iran. Plain-spoken populists running nationalist, anti-establishment campaigns have shown strength the world over.

But there are pitfalls, too. Ahmadinejad is despised by moderates. He’ll have to defend his poor economic record — during his two terms, the country’s economy tanked thanks to international sanctions imposed in response to Iran's refusal to suspend its uranium-enrichment activities, which fueled suspicions that it was secretly pursuing nuclear weapons. And even some conservatives want him out of the race. According to the BBC, some of the country’s most prominent hard-liners have called Ahmadinejad’s decision “unacceptable” and say “will spell the end of his political career.”

If he runs, Rouhani is favored to win. No president has ever lost reelection in Iran, and Rouhani has the support of reformists and moderates, a fragile but essential coalition. For now, though, the field remains crowded. Former vice president Hamid Baghaei, an Ahmadinejad confidant, is running, too. (Baghaei was imprisoned for several months in 2015, allegedly on corruption charges.) Ebrahim Raisi, a conservative cleric closely tied to Khamenei, said he'll run as well, leaving hard-liners fearing a split vote.

At the end of April, the country’s Guardian Council will vet the candidates. The council has the power to block candidates from competing, and it has kept reformists and independents out of parliamentary and presidential elections in the past. This year, though, the council might do the opposite, keeping one of the country’s most conservative politicians out of the race for president.

The council has done it before with a former president. In 2013, it blocked Ali Akbar Hashemi Rafsanjani from the presidential ballot.