Canada, the United States and Mexico on Wednesday mounted a fierce defense of free trade, vowing to deepen economic ties despite an increasingly acrimonious debate about the value of globalization.

U.S. President Barack Obama and Mexican President Enrique Pena Nieto also took swipes at U.S. Republican presidential candidate Donald Trump, who has vowed to renegotiate or scrap the North American Free Trade Agreement (NAFTA) if he wins November's election.

"The integration of national economies into a global economy: that's here, that's done," Obama told a news conference at the end of a summit dubbed the "Three Amigos."

RELATED: New U.S. study shows some positive effects from free trade deals

"And us trying to abandon the field and pull up the drawbridge around us is going to be bad for us," he said after the talks, hosted by Canadian Prime Minister Justin Trudeau.

Trump says free trade has been disastrous, costing thousands of U.S. jobs and depressing wages.

Similar complaints were heard in Britain ahead of a surprise referendum vote last week to leave the European Union and its free trade area.

Obama and Pena Nieto stressed the importance of the relationship between their countries, which has come under strain amid heated U.S. campaign rhetoric.

"Isolationism cannot bring prosperity to a society," Pena Nieto said after bilateral talks with Obama.

Later, at the news conference, Pena Nieto warned of the dangers of populism in a globalized world and defended comments earlier this year in which likened Trump to Adolf Hitler and Benito Mussolini.

"Hitler, Mussolini, we all know the result," he said when asked to explain the comparison. "It was only a call for reflection and for recognition, so that we bear in mind what we have achieved and the great deal still to achieve."

The summit, Trudeau's first and Obama's last, could be the final harmonious one between the three countries if Trump wins the White House in the November U.S. presidential election.

RELATED: Trump's opposition to trade deals fuels internal party opposition

Trudeau, who has generally steered clear of commenting on Trump's remarks since taking power last November, said that regardless of rhetoric the three nations would continue to have tremendously close relations.

Obama has strongly criticized Trump in recent weeks and took aim at the Republican's promises to clamp down on what he says is out-of-control illegal immigration.

The United States, he said, acknowledged public fears about the uncontrolled arrival of foreigners and had worked hard to secure its borders.

"America is a nation of immigrants. That is our strength. ... The notion that we would somehow stop now on what has been a tradition of attracting talent and strivers and dreamers from all around the world, that would rob us of the thing that is most special about America," he said.

Obama – whose progressive social policies are very similar to Trudeau's – later received a rapturous welcome when he addressed the Canadian Parliament. In a speech often interrupted by prolonged applause, he said he understood that some people had genuine concerns about the pace of change.

"If the benefits of globalization accrue only to those at the very top, if our democracies seem incapable of assuring broad-based growth and opportunity for everyone, then people will push back out of anger or out of fear," he said.

"For those of us who truly believe that our economies have to work for everybody, the answer is not to try and pull back from our interconnected world. It is, rather, to engage with the rest of the world, to shape the rules so they're good for our workers and good for our businesses."

Protests over immigration have also been seen in Britain in the wake of the so-called Brexit vote last week, which at one point wiped more than $2 trillion off global equity markets.

RELATED: Canada, Mexico move to improve ties as U.S. election looms

Obama said he expected the world economy would be steady in the short run but expressed longer term concerns about global growth if Brexit went ahead.

Trump also opposes the 12-nation Trans-Pacific Partnership, which was signed in February but may not be ratified by the United States given increasing domestic resistance. Obama said on Wednesday he was committed to ensuring the pact contained high labor and trade standards.

One obstacle to free trade is the dumping of products at artificially low prices, and Trudeau, Obama and Pena Nieto said they agreed on the need for the governments of all major steel-making nations to address excess capacity.

The three also pledged to produce 50 percent of their nations' electricity from clean energy by 2025.