By Agence France-Presse
"They have forgotten that the Berlin Wall collapsed many years ago. Even if there are walls between nations, they must be removed," Rouhani said at a tourism convention in Tehran.
His remarks came after Trump ordered construction of a wall along the US-Mexico border and imposed tough new controls on travellers from seven Muslim countries, among them Iran.
Rouhani did not comment directly on the visa ban, but said Iran had "opened its doors" to foreign tourists since the signing of a nuclear agreement with world powers in 2015.
With more than a million Iranians living in the United States, many families are deeply concerned about the implications of Trump's visa ban, which also affects citizens from Iraq, Libya, Somalia, Sudan, Syria and Yemen.
No visas will be issued for migrants or visitors from these countries for at least 90 days, a restriction which can be extended if the countries in question do not provide extensive information on individuals seeking to enter the United States.
Tehran and Washington have not had diplomatic ties since students stormed the US embassy in Tehran in 1980 following an Islamic revolution that toppled the US-backed shah.