The war-of-words between Tehran and Washington escalated as President Hassan Rouhani and Trump traded threats and warnings.
Rouhani told a crowd of hundreds of thousands marking the anniversary of the 1979 Islamic revolution that "the Iranian people must be spoken to with respect."
"Iranians will make those using threatening language against this nation regret it," he said.
"Anyone threatening Iran's government and armed forces should know that our nation is vigilant."
Trump was asked about the remarks later, responding that "he better be careful."
The US president has toughened the rhetoric against Iran considerably since coming to office.
He has also introduced sanctions after an Iranian missile test.
Many in Trump's inner circle want to see a harder line against Tehran, but have so far shied away from killing a deal that saw Iran get sanctions relief in exchange for curbing its nuclear program.