Tens of thousands of Iranians have braved blizzards to attend rallies marking the 1979 Islamic revolution.
Tehran protesters brave the capital's worst winter in decades
The government had urged people to turn out to show support for its nuclear programme amid pressure led by the US.
President Mohammad Khatami told them Iran would become a "burning hell" for any country that invaded it.
Meanwhile, in Berlin, 1,000 or more Iranian exiles marched in protest, demanding democratic change in their home country.
The rallies were held to mark the toppling in 1979 of the shah and the return of late leader Ayatollah Khomeini.
The biggest demonstration in Iran took place in the capital Tehran's snowy Azadi square, where tens of thousands gathered to hear an address by their president.
Mr Khatami told them US "threats" of military action were "just part of the psychological war and the consequence of their failures".
He said: "All the people of Iran are united against any attack and any threats. Any invader will find Iran to be a burning hell for them."
The crowds turned out despite the city being virtually paralysed by heavy snowfalls in its worst winter for decades.
The BBC's Frances Harrison in Tehran says those in power want to show they have genuine popular support, and make it far more difficult for the Americans to topple the regime.
The counter-demonstration in Berlin went ahead despite originally being banned for alleged links with the exiled People's Mujahideen opposition, which is branded a terrorist group by the United States and the European Union.
A German court overturned the ban.
Iranian exiles want to see the end of Iran's theocracy
Demonstrators marched from western Berlin to the Brandenburg Gate, carrying signs in French and German calling for democracy in Iran and supporting the Mujahideen's exiled co-leader, Maryam Rajavi.
Some of them said they wanted a peaceful revolution, but other marchers called for an invasion to remove the theocratic government from power.
US President George Bush has refused to rule out military action to prevent Iran from developing nuclear weapons - though he also emphasised the role of diplomacy.
Tehran insists its nuclear programme is for peaceful purposes.
Mr Khatami said on Thursday: "We give our guarantee that we will not produce nuclear weapons because we are against them and do not believe they are a source of power."
But he added: "We will not give up peaceful nuclear technology."