Rafsanjani now stands as the main hope for reformists, who were crushed and left leaderless after a government crackdown on mass street protests following Ahmadinejad's disputed 2009 election victory. A win by Rasfanjani, who is seen as a centrist candidate and previously served as president from 1989-1987, could open the way for an easing of tensions with the outside world and distance Iran from Ahmadinejad's bombastic style and the hardline policies of the Islamic Republic's conservative camp.
Mashaei, on the other hand, would mark a continuation of Ahmadinejad-era policies.
"I'll consider it my obligation to continue the path of Ahmadinejad's government," Mashaei told reporters after registering Saturday.
Mashaei has long been Ahmadinejad's close confidant, and the president's son is married to Mashaei's daughter. State TV showed a smiling Ahmadinejad accompanying Mashaei as he submitted his papers Saturday, and the president raised his aide's hand in a gesture of support.
"Mashaei means Ahmadinejad, and Ahmadinejad means Mashaei," the official IRNA news agency quoted Ahmadinejad as saying.
All candidates must be approved by the election overseers, known as the Guardian Council, to make it onto the ballot, and Mashaei's role in a messy power struggle in recent years between Ahmadinejad and the Islamic establishment could lead to him being knocked out the race.
Hardliners accuse Mashaei of being the leader of a "deviant current" that seeks to undermine Islamic rule and compromise the Islamic system. Some critics have even claimed he conjured black magic spells to fog Ahmadinejad's mind.
The Guardian Council will announce the handful of accepted candidates on the ballot later this month.
The slate is almost certainly to be heavily stacked with those considered loyal to the Supreme Leader Ayatollah Ali Khamenei, who has been angered by challenges to his authority by Ahmadinejad and the president's allies. Among the presumed front-runners is senior Khamenei adviser Ali Akbar Velayati, Tehran Mayor Mohammad Bagher Qalibaf, prominent lawmaker Hadad Adel and top nuclear negotiator Saeed Jalili.
Prominent pro-reform figures, such as former President Mohammad Khatami, will not seek spots on the ballot. That leaves opposition and liberal groups the option of boycotting the election or falling behind one of the candidates cleared by the ruling clerics.
All key policies in Iran are made by the clerics and their inner circle, including the powerful Revolutionary Guard. But the president is the international face of the country, and is responsible for increasingly important areas such as the nation's stumbling economy.
Most of the main candidates have vowed to shun Ahmadinejad's style and to try to reduce tensions with the West and its allies. But all strongly support Iran's ability to maintain a full-scale nuclear program, including uranium enrichment. The U.S. and others fear Iran could eventually develop nuclear weapons from the program, but Tehran insists it only seeks reactors for energy and medical research.
The diplomatic impasse has been the main driver of the country's economic morass tough oil and banking sanctions imposed by the West over the nuclear program have cut income from key oil and gas exports by about 50 percent.
The decision of Rafsanjani and Mashaei to run greatly reduces the chance of a Khamenei loyalist winning the vote, and puts pressure on the conservative camp to reduce the number of hardline figures in the race to avoid splitting the vote.
Mashaei, who has drawn the wrath of Khamenei in recent years, said he will respect the law if the council scratches his candidacy.
"All must give in to the law," he told reporters.