Mr. Leylaz said that Mr. Moussavi’s announcement to run came unexpectedly last week, even though Mr. Khatami had consulted with him before announcing his own bid for the office on Feb. 8. Before the announcement, Mr. Khatami had said that he would run only if Mr. Moussavi did not, to avoid diluting the reformist vote.

“Mr. Khatami was offended and felt betrayed,” Mr. Leylaz said.

Mr. Khatami, 65, won a landslide victory in 1997 and was in office for two terms until 2005. A charismatic leader, he was expected to draw considerable support in the coming election. More than 20,000 supporters showed up at his speech last week in the southern city of Shiraz, despite government restrictions.

But Mr. Khatami also has strong enemies among politicians who oppose more political and social openness. His reform agenda, which included an easing of tensions with the West, suffered major setbacks when he was in office. Powerful hard-line institutions blocked many of his efforts, and many of his allies were jailed.

Mr. Moussavi was the country’s prime minister from 1980 to 1988. He is well remembered by many Iranians for managing the country during its eight-year war with Iraq. His presidential platform is not yet clear, but in the past he supported protectionist economic policies.

Mr. Moussavi, who is also a painter and architect, stayed out of politics for the past two decades and had turned down calls to run for president in previous elections. Mr. Ahmadinejad is supported by the conservative Iranian establishment, but his economic policies have unleashed inflation of over 25 percent, and two major setbacks last week suggested that he might be losing support ahead of elections.

Last week, Parliament rejected a major element of his proposed budget to cut energy subsidies and to distribute the money directly among the poor. Another reformist candidate, Mehdi Karroubi, has said that he will remain in the race.