Hundreds of thousands of Iranians marched and some burned United States flags to mark the revolution as Tehran showed off ballistic missiles in defiance of USA efforts to curb its military power.
Others carried pictures of Ayatollah Ruhollah Khomeini, the Shi'ite religious leader whose return from exile led to the ouster of Iran's Shah.
Along with the chants "Death to America" and banners bearing slogans calling for "Death to Israel", Monday's marches were also a backdrop to the military's display of Iranian-made missiles, which authorities showcase every year during anniversary celebrations.
Iranian President Hassan Rouhani told Iranians they should resist a "conspiracy" involving Washington.
He said that while Iran will continue to have "constructive engagement" with the global community, it will not ask for permission to produce any type of missile it wants.
After decades of hostility with the United States, the Islamic Republic vowed to increase its military strength despite mounting pressure from Western countries.
A number of Israeli and American flags were set on fire by the crowds.
The remarks came a day after Trump tweeted about 40 years of "corruption, repression and terror", reacting to the 40th anniversary of Iran's Islamic Revolution, which he claimed was followed by "the regime in Iran producing only 40 years of failure". Trump also reestablished US economic sanctions against Iran.
It was not clear whether the amnesty would also apply to political prisoners.
Delhi: Massive fire breaks out in hotel, 9 die
Three people jumped from the blazing structure even as 25 fire tenders rushed to the spot after receiving a call at 4.30 am. Last week, a fire broke out in a hospital in Noida, forcing an emergency evacuation of scores of patients and other people.
Iran vaunts military, taunts United States as revolution turns 40
Last year, Iran cracked down on protests over poor living standards. "We will not let America become victorious." he said. State TV showed crowds defying rainy weather and carrying Iranian flags while shouting anti-Israeli and anti-US slogans.
England World Cup winning goalkeeper Gordon Banks dies, aged 81
In eight years at Leicester, he was runner-up in two FA Cup finals and won the League Cup in 1964, before joining Stoke in 1967. In December, Banks took on the role of "FIFA Legend" to take part in the Russian Federation 2018 World Cup Final Draw in Moscow.
He also blasted a US "conspiracy" against the country, saying, "The presence of people today on the streets all over Islamic Iran. means that the enemy will never reach its evil objectives".
But despite the official festivities today's Islamic republic faces acute economic challenges as it struggles with a mix of domestic hardships and U.S. sanctions.
Later that year, Iranian militants took dozens of people hostage at the US Embassy in Tehran, sparking the first round of sanctions from Washington and causing a lasting rupture in countries' relations. Iranian people have and will have some economic difficulties but we will overcome the problems by helping each other, ' Rouhani said.
State television offered blanket coverage of the commemorations, showing marches in cities ranging from Abadan in southwestern Iran to Mashhad in the northeast.
"At the revolution's 40 anniversary we are on top of scientific achievements like nanotechnology or accurate missiles", he said.
A senior commander in Iran's Revolutionary Guards said Tehran would not withdraw forces from the region, dismissing USA calls for Iranian clout to be curbed.
He compared the U.S. sanctions and economic hardships to "riding a bicycle when someone puts a stick in the wheels" but pointed to advances in other fields as more than making up for them.
Soldiers, students, clerics and black-clad women holding small children flocked to the streets of cities and towns, many carrying portraits of Khomeini and Iran's current supreme leader, Ayatollah Ali Khamenei.