On February 11, 1979, Iran's army declared its neutrality, paving the way for the collapse of the Shah Mohammad Reza Pahlavi, the United States' closest ally in the Middle East.
State TV showed large crowds defying frigid weather and carrying Iranian flags while chanting "Death to Israel, Death to America," trademark chants of the revolution which ousted the United States' most important ally in the Middle East.
One banner read: "Much to the dismay of America, the revolution has reached its 40th year."
The large turnout in state-sponsored rallies came as Iranians face rising prices, food shortages and high inflation that have triggered waves of protests.
US President Donald Trump pulled out of Iran's 2015 nuclear deal with world powers last year and re-imposed sanctions on Tehran, dealing a blow to the country's economy. Iranian officials said the move amounted to "economic warfare"
In a speech at Tehran's Azadi (Freedom) square, President Hassan Rouhani dismissed US efforts to isolate Iran, saying US sanctions could not break the Islamic Republic.
"We will not let America become victorious Iranian people have and will have some economic difficulties but we will overcome the problems by helping each other," he said in a speech.
Iranians carried cardboard cutouts of dogs. One had the face of Trump and the other the face of Prime Minister Benjamin Netanyahu.
The United States and its Arab allies have viewed Iran with great suspicion since the Islamic Revolution swept the Shah from power in 1979, fearing Khomeini's radical ideology would inspire Islamic militants across the Middle East.
Today Iran enjoys influence through proxies in Iraq, Syria, Lebanon and Yemen, raising concerns in Sunni Saudi Arabia, which accuses its rival of trying to dominate the Middle East. Tehran denies the allegations.
The world saw when Iran decided to help people of Syria, Iraq, Lebanon, Palestine and Yemen, they achieved victory. The enemies are now confessing to their defeat," said Rouhani.
A senior commander in Iran's Revolutionary Guards said Tehran would not withdraw its forces from the region, dismissing US calls that Iranian regional influence should be curbed.
"The enemy cannot ask us to leave the region. They must leave the region," said Brigadier General Hossein Salami, deputy head of Iran's Revolutionary Guards. "We will help any Muslim anywhere in the world."
Iran was determined to expand its military power and ballistic missile programme despite mounting pressure from hostile countries to curb Iran's defensive work, state TV reported Rouhani as saying.
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.