“We’ve taken a lot of barbs and a little abuse,” he said.

Turning to Mr. Trudeau, whom he referred to as a “great friend,” he said, “It’s been a battle.” But battles, he added, sometimes make “great friendships.”

Mr. Trudeau smiled politely.

Despite the smiling, disagreements remain between the two leaders.

In his remarks, Mr. Trudeau urged Mr. Trump to remove punishing tariffs on imports of steel and aluminum from Canada, saying they imposed a “major obstacle” on the Canadian economy.

As Mr. Trudeau spoke, Mr. Trump appeared stone-faced, but broke into a pensive smile at one point. When Mr. Trudeau ended his comments, the American president shook his hand with a brevity that contrasted with his usual vigorous greetings.

[Read more about the signing and the acrimonious talks that led to it.]

Some in the Canadian news media presented the deal as a sign that, at least for now, a full-on trade skirmish had ended.

“ ‘Battle’ over as Trudeau, Trump, Peña Nieto sign ‘new Nafta,’” said a headline from the CBC, the national broadcaster.