TEHRAN, Iran (AP) — 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 Donald 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 county."

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."

Ahmadinejad previously served two four-year terms from 2005 to 2013. Under Iranian law, he became eligible to run again after four years out of office, but he remains a polarizing figure, even among fellow hard-liners.

Corruption allegations surrounded Ahmadinejad's presidency and two of his former vice presidents were jailed, including Baghaei. Iran's economy also suffered under heavy international sanctions during his administration because of Western suspicions that Tehran was secretly pursuing nuclear weapons. Iran insists its nuclear program is for peaceful purposes.

Internationally, Ahmadinejad also remains known for repeatedly questioning the scale of the Holocaust and predicting Israel's demise.

Ahmadinejad does, however, maintain popularity among the poor for his populist policies and subsidies he offered while in office.

More than 280 people have filed as possible candidates since registration began Tuesday, including 13 women. Registration remains open until Saturday.

Under Iran's electoral system, all applicants must be vetted by the Guardian Council, a clerical body that will announce a final list of candidates by April 27. The council normally does not approve dissidents or women for the formal candidate list.

Ahmadinejad's candidacy may be a stunt to ensure at least one of his acolytes makes the cut. Ahmadinejad himself described his decision to run as intended to help Baghaei. Esfandiar Rahim Mashaei, another of the former president's close allies, also registered Wednesday.

"People are reading it as saying he knows he's going to be disqualified, but he's doing it so that the Guardian Council doesn't disqualify both Baghaei and him as that would look like they're eliminating all of that camp," Geranmayeh said.

The May 19 election is seen by many in Iran as a referendum on the 2015 nuclear agreement and other efforts to improve the country's sanctions-hobbled economy. Under the nuclear deal, Iran agreed to curb its uranium enrichment in exchange for the lifting of international sanctions.

Since the deal, Iran has signed multi-billion-dollar contracts with airplane manufacturers Boeing Co. and Airbus. The benefits have yet to trickle down to the average Iranian, though, fueling some discontent.

Incumbent President Hassan Rouhani is widely expected to seek re-election after his administration negotiated the atomic accord, though he has not filed or formally declared his candidacy. Ebrahim Raisi, a hard-line cleric close to the supreme leader, also has declared his candidacy and is seen by some as the choice of the Revolutionary Guard, a powerful paramilitary organization that also has vast economic holdings.

Every Iranian president since Khamenei himself took the presidency in 1981 has won re-election, making Rouhani the presumed front-runner long before the vote. Rouhani also is presumed to maintain support among liberals and those wanting tensions eased with the West, though polling is difficult.

News of Ahmadinejad's bid became the topic of discussion across Tehran, leading news bulletins Wednesday night. Ali Akbar Javanfekr, Ahmadinejad's media adviser during his presidency, told one local news site that "Ahmadinejad will not withdraw."

"He will go until the end," Javanfekr said.

Some, like 26-year-old electrician Mahmoud Karegar, said Ahmadinejad should be allowed to run.

"I think the ruling system wants him to come as a reaction to Trump," Karegar said.

Others were less enthusiastic.

"It was very weird, but it could be entertainment for people," 31-year-old nurse Roya Khani said. "I won't vote for him."

___

Gambrell reported from Dubai, United Arab Emirates. Associated Press writer Adam Schreck in Dubai contributed to this report.