By Parisa Hafezi

ANKARA (Reuters) - Hundreds of thousands of Iranians rallied on Friday to swear allegiance to the clerical establishment following U.S. President Donald Trump's warning that he had put the Islamic Republic "on notice", state TV reported.

On the anniversary of Iran's 1979 Islamic Revolution, which toppled the U.S.-backed shah, marchers including hundreds of military personnel and policemen headed towards Tehran's Azadi (Freedom) Square.

They carried "Death to America" banners and effigies of Trump, while a military police band played traditional Iranian revolutionary songs.

State TV showed footage of people stepping on Trump's picture in a central Tehran street. Marchers carried the Iranian flag and banners saying: "Thanks Mr. Trump for showing the real face of America."

"America and Trump cannot do a damn thing. We are ready to sacrifice our lives for our leader", a young Iranian man told state TV in a reference to Supreme Leader Ayatollah Ali Khamenei.

Last week, Trump put Iran "on notice" in reaction to a Jan. 29 Iranian missile test and imposed fresh sanctions on individuals and entities. Iran said it will not halt its missile program.

Iranian leading religious and political figures, including Pragmatist President Hassan Rouhani had called on Iranians to join the rally on Friday to "show their unbreakable ties with the Supreme Leader and the Islamic Republic".

VIGILANT

In a speech marking the revolution's anniversary, Rouhani urged Iran's faction-ridden elite to seek unity amid increased tensions with the United States.

"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 told the crowd at Azadi Square.

"Our nation is vigilant and will make those threatening Iran regret it ... They should learn to respect Iran and Iranians ... We will strongly confront any war-mongering policies."

The rallies were rife with anti-U.S. and anti-Israeli sentiment. Some carried pictures of Trump, Israeli Prime Minister Benjamin Netanyahu and British Prime Minister Theresa May captioned "Death to the Devil Triangle".

Story continues

"This turnout of people is a strong response to false remarks by the new leaders of America," Rouhani told state TV, which said millions had turned out at rallies across Iran.

U.S. flags were burned as is traditional although many Iranians on social media such as Twitter and Facebook used the hashtag #LoveBeyondFlags to urge an end to flag-burning during the anniversary.

They also thanked Americans for opposing Trump's executive order banning entry to the United States to travellers from seven mainly Muslim countries, including Iran. Trump's travel ban is being challenged in U.S. courts.

Some marchers carried banners that read : "Thanks to American people for supporting Muslims".

Both U.S.-based social media sites are blocked in Iran by a wide-reaching government censor but they are still commonly used by millions of Iranians who use special software to get around the restrictions. Iranian officials, including Khamenei, have Twitter and Facebook accounts despite the ban.

Trump has criticized a nuclear deal reached between Iran, the United States and other major powers in 2015 aimed at curbing the country's nuclear work. Most of the sanctions imposed on Iran were lifted last year under the deal.

Rouhani defended the deal, which his hardline rivals oppose as a concession to pressure from Washington, saying it protected the Islamic Republic’s rights to nuclear power, ending Iran's political isolation and crippling economic sanctions.

(Writing by Parisa Hafezi; editing by Ralph Boulton; Editing by Catherine Evans)