Trump was asked in a brief appearance in the press cabin aboard Air Force One about Rouhani's reported remarks to a rally in Tehran to celebrate the anniversary of the Islamic Revolution.
Rouhani was quoted in media reports as saying Iran had shown in the 38 years since the revolution that "it will make anyone who speaks to Iranians with the language of threats regret it."
"He better be careful," Trump said.
Trump on Feb. 2 put Iran "on notice" over charges that Tehran violated a nuclear deal with the West by test-firing a ballistic missile, taking an aggressive posture towards Iran that could raise tensions in the region.
Trump made the comments about Rouhani while flying on the presidential jet carrying him and Japanese Prime Minister Shinzo Abe for a weekend at Trump's Mar-a-Lago retreat in Palm Beach, Florida.