Iranian President Hassan Rouhani waves to supporters before giving a speech at a rally in Tehran to mark the 35th anniversary of the Islamic revolution. (Atta Kenare/AFP/Getty Images)

Iranian President Hassan Rouhani marked the anniversary of the founding of the Islamic republic on Tuesday with a mix of defiance and moderation, telling a huge crowd of Iranians that “no single political faction can rule the country, and all political groups must have a share in running the country.”

“We want to increase national unity and clear our hearts from some past events,” said Rouhani, who was elected last June after campaigning as a reformer who could heal the country’s internal divisions and ease its international isolation.

At the same time, a week before the next round of negotiations with world powers over Iran’s controversial nuclear program, Rouhani was resolute about the country’s right to develop its own energy sources and, separately, to protect itself.

“I say it clearly, Iran will maintain a permanent nuclear program,” he told tens of thousands of Iranians gathered to mark the 35th anniversary of the founding of the Islamic republic in 1979.

Tehran says its nuclear program is peaceful and permitted under the Nuclear Non-Proliferation Treaty. But the West, Israel and some Arab nations fear that Iran is trying to start a clandestine weapons program.

Rouhani said the upcoming talks in Vienna will provide an opportunity to end the standoff, but he warned of calamity if the two sides cannot come to a comprehensive agreement.

“The talks are a historical test for Europe and the United States, and if they respect the interests of our nation and cooperate in a lawful way, they will hear a positive response from our nation,” he said. “But if they repeat the mistaken approaches of the past, it will be harmful for themselves, the region and world stability.”

The anniversary celebration in Tehran’s Azadi (Liberty) Square, the city’s largest, felt in some ways like a carnival, with vendors selling balloons and sandwiches, and puppet troupes entertaining children. But the festive atmosphere was punctuated with revolutionary fervor. Volunteers handed out posters and fliers that repeated the old slogan “Death to the U.S.A.,” as well as newer ones such as “We are eager for the options on the table” — an apparent reference to statements by U.S. officials that Washington reserves the right to use military force if Iran and world powers cannot finalize a deal.

One booth held what it called an “ ‘Effigy of Arrogance’ building competition,” offering a gold coin for the most realistic likeness of one of Iran’s adversaries — President Obama and Israeli Prime Minister Benjamin Netanyahu chief among them.

An organizer of the competition said he was not hopeful that his country and the West would reach a compromise over Iran’s nuclear program. “Everything our leaders do to try and improve the situation, like entering the nuclear negotiations in good faith, is rejected by the other side,” Mohammad Nouri said.

Others in the crowd were more optimistic. “I participated in the revolution and then in the war with Iraq. I did it for my dignity and that of my country,” hotel worker Esmail Heydarpour said. “But now the realities of our day-to-day politics tell us that if we have relations with the U.S., the situation will be much better for us.”

Tehran often uses the anniversary of the 1979 revolution to announce important technical and military achievements, and this year was no exception.

On Monday, Defense Minister Hossein Dehghan said the country had successfully tested a new generation of long-range ballistic missiles. The tests should have no bearing on the upcoming Vienna talks, said Deputy Foreign Minister Abbas Araghchi, one of Iran’s lead nuclear negotiators.

“Our talks with the six world powers are only about the nuclear issue. We will never engage in talks about other matters,” Araghchi said. “We made it clear to them in the past, and we also made it clear for the upcoming talks.”

In his speech, Rouhani asked Iranians to try to come together to move beyond the scars and deep divisions generated by the contested 2009 reelection of Mahmoud Ahmadinejad as president and the months of protests that followed.

“We need to move forward,” Rouhani said.