TEHRAN, Iran — Stunning Iran and disregarding the words of its supreme leader, former President Mahmoud Ahmadinejad registered Wednesday to run in the country’s May presidential election and upended a contest largely expected to be won by its moderate incumbent.

Though Ahmadinejad still might not be approved for the ballot by Iran’s clerically overseen government, merely the mention of the Holocaust-questioning populist might energize discontent hard-liners who want a Persian answer to U.S. President Trump.

Ahmadinejad’s candidacy also comes as Trump has threatened a reappraisal of Iran’s nuclear deal with world powers and as fissures still linger inside Iran after his contested 2009 re-election, which brought massive unrest.

Associated Press journalists watched as stunned election officials processed Ahmadinejad’s paperwork on Wednesday. Asked about Ahmadinejad’s decision, one Tehran-based analyst offered a blunt assessment.

“It was an organized mutiny against Iran’s ruling system,” said Soroush Farhadian, who backs reformists.

Ever the showman, a smiling Ahmadinejad made “V for Victory” hand signals and walked his former Vice President Hamid Baghaei through the process of registering first. Just when it appeared Ahmadinejad would be leaving, he turned around and returned to the Interior Ministry’s registration desk, pulling out his identification documents with a flourish in front of a melee of shouting journalists.

Ahmadinejad’s decision shocked Iran as Supreme Leader Ayatollah Ali Khamenei offered a thinly veiled warning in September that his candidacy would be a “polarized situation” that would be “harmful for the country.”

That referenced Ahmadinejad’s disputed re-election in 2009, which sparked massive protests and a sweeping crackdown in which thousands of people were detained and dozens were killed.

Ahmadinejad on Wednesday described comments by the supreme leader as “just advice” in a news conference shortly after submitting his registration.

“His advice does not prevent me from running,” he said. “There is extensive pressure on me from dear people of different walks of life as their small servant to come to the election.”

There was no immediate reaction from the supreme leader’s office. While Khamenei has final say on all state matters, Ahmadinejad’s relationship with him had strained by the end of his time in power.

“It’s in clear defiance of what the supreme leader had stated very openly and very publicly,” said Ellie Geranmayeh, a policy fellow at the European Council on Foreign Relations. “What Ahmadinejad has done is quite crushing … but he also had a habit of doing this while he was president in his second term.”