Trump on Wednesday ordered the construction of a US-Mexican border wall, a major promise during his election campaign, as part of a package of measures to curb illegal immigration.
"Today is not the time to erect walls between nations. They have forgotten that the Berlin wall fell years ago," Rouhani said in a speech carried live on Iranian state television.
Mexican president condemns Trump's wall plan
"To annul world trade accords does not help their economy and does not serve the development and blooming of the world economy," Rouhani told a tourism conference in Tehran. "This is the day for the world to get closer through trade."
The protectionist-minded Trump formally withdrew the United States from the Trans-Pacific Partnership trade deal on Monday, fulfilling a campaign pledge to end American involvement in the 2015 pact.
Rouhani, a pragmatist elected in 2013, thawed Iran's relations with world powers after years of confrontation and engineered its 2015 deal with them under which it curbed its nuclear program in exchange for relief from sanctions.
Trump orders building of Mexico border wall
For Trump's predecessor Barack Obama, the agreement was a landmark foreign policy achievement but the new president has threatened to annul it or seek a better deal. The other five powers party to the deal have reaffirmed their commitment to it.
Rouhani said earlier this month that Trump could not unilaterally cancel the nuclear deal and that talk of renegotiating it was "meaningless".
Since sanctions were lifted, Iran has signed major deals with Western firms, particularly with planemakers Airbus (AIR.PA) and Boeing (BA.N).
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ