The six-mile-long downtown Enghelab, or Revolution, Street was decorated with huge balloons as loudspeakers blared out nationalist songs.
Banners held by marchers or hung along the streets bore slogans including "Death to America", "Death to Israel", "we will trample on America", "40 years of challenge, 40 years of USA defeats".
In a speech at Tehran's Azadi (Freedom) square, Rouhani said USA efforts to separate Iran from other countries would fail.
Prices of basic foodstuffs have soared since President Donald Trump withdrew Washington from world powers' 2015 nuclear deal with Iran previous year and reimposed sanctions on Tehran.
In July 2017, Bolton told an MEK gathering convention that "the outcome of the president's policy review should be to determine that the Ayatollah Khomeini's 1979 revolution will not last until its 40th birthday".
He vowed to boost Iran's military and ballistic missile program. "Iran continues to seek nuclear weapons to intimidate people all around the globe and ballistic missiles to use as delivery systems".
"We do not and we will not ask permission for producing any type of missiles from anybody", Rouhani said in his speech Monday, though he stressed that Iran would "continue constructive engagement" with the worldwide community.
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.
Hakeem Al-Araibi to be released by Thailand court
Navy's 5th Fleet, said the country "reaffirms its right to pursue all necessary legal actions against" al-Araibi. Araibi was released from prison shortly afterward, and Thai officials said he would fly out that night.
Gen. Qassem Soleimani, the head of Iran's elite Quds Force, attended a rally in the southern city of Kerman. He said he wanted to teach his son to support the revolution.
Mahmoud Hemmati, 35, was pushing his 68-year-old mother, Parivash Fakheri, in a wheelchair.
"On the revolution's 40th anniversary we are at the top for scientific achievements like nanotechnology or accurate missiles", he said.
One sign read, "Much to the dismay of America, the revolution has reached its 40th year".
"I know there are many economic problems today, but that is something different from our revolution", she said.
In January, Rouhani said Iran was dealing with its worst economic crisis since the Shah was toppled.
Ayatollah Khamenei recently said when they chant "death to America" they really just mean death to President Donald Trump and his Cabinet.
Trump was echoed by National Security Adviser John Bolton, who published a spate of tweets, in which he argued in particular that "the 40th anniversary of the Iranian regime only serves to highlight four decades of failure and broken promises".