Hundreds of thousands of Iranians have taken to the streets to begin a nationwide celebration of the 38th anniversary of the country's 1979 revolution.

Marchers chanted traditional slogans against the United States and Israel as they gathered in the main streets of the capital Tehran on Friday.

In an address to crowds gathered at the Azadi [Freedom] Square, President Hassan Rouhani issued a warning to those using "threatening language" against the country.

OPINION: Trump and Iran - Scenarios of escalation

"Some inexperienced figures in the region and America are threatening Iran ... They should know that the language of threats has never worked with Iran," Rouhani said.

"They should learn to respect Iran and Iranians ... We will strongly confront any warmongering policies."

The official Mehr News Agency reported that Major General Qassem Soleimani, the commander of the Quds Force, and Ali Akbar Salehi, head of the atomic energy agency, had also joined the Tehran march.

The commemoration came as US President Donald Trump was engaged in a war of words with Iran's leadership, saying he had put Tehran "on notice" over a recent ballistic missile test and imposing new sanctions on Iranian businessmen and companies.

Responding in an Al Jazeera interview, Iran warned of "dark days" if the US was to carry out a military attack, insisting its missile test did not violate the historic nuclear deal it reached with Western powers in 2016.

Al Jazeera's Dorsa Jabbari, reporting from Tehran, said the the country's Supreme Leader Ayatollah Ali Khamenei had called on people to take to the streets to "show the world that the US threats do not mean anything inside Iran".

Jabbari said that, regardless of their political affiliations, many young people had said they would do "whatever it takes to defend the country".

State television aired footage of enthusiastic celebrations in Tehran and other cities and towns across the country, many of them taking place in sub-zero weather.

The commemorations mark February 11, 1979, when followers of Ayatollah Ruhollah Khomeini ousted the US-backed Shah Reza Pahlavi.