President Hassan Rouhani evoked the dramatic 1989 collapse of the Berlin Wall to note that no such structure can stand between nations, referring to a controversial US plan to build a wall along its southern borders with Mexico.
"It is no time to construct walls between nations. Some appear to have forgotten the fall of the Berlin Wall some years ago," the president said in an address to a tourism conference in Tehran on Saturday.
"We should remove any existing wall between nations and today's world does not allow forcing a separation between people from different countries," he was quoted as saying by his official website.
The Berlin Wall was built in 1961 during the communist rule to stop East Germans fleeing to the West.
At least 138 people were killed trying to escape to West Berlin, but on November 9, 1989, hundreds of protestors breached the heavily guarded 160-km concrete barrier.
One year after the incident that marked the end of the Cold War, East Germany and West Germany reunited, although political, economic and social divisions still remain.
The US plan to construct the wall, championed by Republican President Donald Trump, has prompted an outcry from immigrant advocates and Democratic lawmakers who said Trump was jeopardizing the rights and freedoms of millions of people while treating Mexico as an enemy, not an ally, and soiling America's historic reputation as a welcoming place for immigrants of all stripes.
The White House has claimed that the wall would stem the flow of drugs, crime and illegal immigration into the United States, Reuters reported.
Mexicans are also enraged by the plan. Trump's policies, including his demand that the North American Free Trade Agreement with Mexico and Canada be renegotiated or scrapped, have put Mexico's government on the defensive.
In an ABC News interview, Trump said the wall's construction would start within months, with planning starting immediately, and that Mexico would pay back to the United States "100 percent" of the costs. Mexican officials have said they will not pay for the wall.
The cost, nature and extent of the wall remain unclear.
In response to Trump's demand, Mexican President Enrique Pena Nieto announced in a tweet on Thursday that he was scrapping a planned trip to meet with his US counterpart.
The two, however, held a phone conversation on Friday, which the US leader described as friendly.