BUENOS AIRES — President Trump and his Mexican and Canadian counterparts sought to put the acrimony of the past two years behind them on Friday as they signed a new agreement governing hundreds of billions of dollars in trade among the neighbors that underpins their economies.
Meeting for the first time since the revised North American Free Trade Agreement was sealed, Mr. Trump, President Enrique Peña Nieto of Mexico and Prime Minister Justin Trudeau hailed the results as a boon for workers, businesses and the environment, even as they alluded to the harsh talks that had preceded this day.
“We worked hard on this agreement,” Mr. Trump said, with the other leaders beside him at a ceremony on the sidelines of an international summit meeting in Buenos Aires. “It’s been long and hard. We’ve taken a lot of barbs and a little abuse, and we got there. It’s great for all of our countries.”
Mr. Trump did not say that he was the one who had dished out most of the barbs and much of the abuse, but he insisted that he had come out of the process with a stronger relationship with the two leaders. He said that Mr. Trudeau, whom he once assailed as “very dishonest and weak,” had become “a great friend,” despite it all.
“It’s been a battle,” he added, “and battles sometimes make great friendships.”
Mr. Trudeau did not respond directly but seemed to refer implicitly to speculation that he might not attend the ceremony and send a lower-level official to sign in his place. His schedule for Buenos Aires did not initially list the ceremony. But he opted to attend anyway, saying the deal “maintains stability for Canada’s entire economy” and removes the dangers associated with a threatened United States withdrawal.
“That’s why I’m here today,” he said. “The new agreement lifts the risk of serious economic uncertainty that lingers throughout a trade renegotiation process.”
Mr. Trudeau pointedly referred to the accord as the “new North American Free Trade Agreement” and described it as “modernizing Nafta,” despite Mr. Trump’s effort to rebrand it as the United States-Mexico-Canada Agreement.
The Canadian leader also used the occasion to press Mr. Trump on steel and aluminum tariffs, which remain unresolved. “Make no mistake, we will stand up for our workers and fight for their families and their communities,” Mr. Trudeau said. “And Donald, it’s all the more reason why we need to keep working to remove the tariffs on steel and aluminum between our two countries.”
The new agreement represents a signature achievement for Mr. Trump, who has long derided nearly every major trade deal that the United States has entered. Negotiators reached a last-minute deal in September following months of acrimonious talks that raised doubts about whether any accord was possible. Mr. Trump repeatedly assailed his counterparts and threatened to scrap Nafta altogether.
In signing the agreement on Friday, Mr. Trump sought to ratchet up the pressure on President Xi Jinping of China, with whom he will meet on Saturday amid an escalating trade war. Mr. Trump has already imposed tariffs of 10 percent on many Chinese goods and has threatened to raise them to 25 percent. But he has signaled in recent days that he may be able to reach an understanding with Mr. Xi during a dinner this weekend to forestall such a move.
Mr. Trump also hoped to create some momentum behind the Mexico-Canada deal back home, where it still requires the approval of Congress. With Democrats having won control of the House in the midterm elections, the president faces the challenge of convincing skeptics in both parties that he made enough improvements to Nafta.
In nearly two years in office, Mr. Trump has made little effort to forge bipartisan consensus in Congress, as the Republicans controlled both chambers. But the politics of trade are more complex than the usual partisan lines, with skeptics of globalization in both parties.
Mr. Trump expressed confidence that he would win easy approval by Congress, saying, “It’s been so well reviewed I don’t expect to have very much of a problem.”
The signing came shortly after a separate ceremony, hosted by Mr. Peña Nieto, presenting Jared Kushner, Mr. Trump’s son-in-law and senior adviser, with Mexico’s highest award for foreigners in honor of his role in negotiating the trade agreement. The announcement this week that the award would go to Mr. Kushner drew waves of criticism, given the insulting language Mr. Trump has used about Mexicans, including his description during the presidential campaign of illegal immigrants from Mexico as rapists.
In accepting the Order of the Aztec Eagle from Mexico, Mr. Kushner insisted that the president’s harsh language did not reflect the trust that has developed between the leaders of the two countries.
“Through your direction and leadership we were able to accomplish a lot of great things,” Mr. Kushner told Mr. Trump at the ceremony. “While there has been a lot of tough talk, I have seen the genuine respect and care that President Trump has for Mexico and the Mexican people, and I do believe we have been able to put that in the right light.”
While analysts said the new trade agreement is not as much of a transformation as Mr. Trump suggests, it does rewrite the rules for an extraordinary amount of commerce between the three nations. The United States did $581.6 billion in business with Canada last year, and $557.6 billion with Mexico, making them the nation’s second- and third-largest trading partners.
Under the agreement, American dairy farmers would be allowed greater access to Canada’s market to sell their cheese, milk and other products. A higher percentage of cars would have to be manufactured in North America and factories must pay their workers an average of $16 an hour or more to be exempted from tariffs. The deal also updates provisions on the digital economy, agriculture and labor unions, but it preserves an international dispute mechanism that Mr. Trump had sought to eliminate.
The deal has drawn mixed reviews, with supporters of free trade saying it does not do enough to promote cross-border commerce and protectionists complaining that it does not do enough to protect the environment, raise wages and stop the outsourcing of jobs.
Senator Chuck Schumer of New York, the Democratic minority leader and a longtime critic of Nafta, said on Friday that the new agreement could not be “simply a rebranding of the same old policies that hurt our economy and workers for years” if it is to pass Congress.
“It must prove to be a net benefit to middle-class families and working people in our country and must have strong labor and environmental protections, which in the present deal are too weak,” he said.
A dozen Republican senators sent Mr. Trump a letter last week urging him to submit the agreement for approval in the lame-duck session of the departing Congress before Democrats assume control of the House in January.
Senator Patrick J. Toomey, a Republican from Pennsylvania, who signed the letter, said the deal still needed to be improved even now, despite what he considered the improvements to the trade structure between the three nations.
“Unfortunately, the benefits of these enhancements are more than offset by the trade-limiting provisions,” he said in a statement. “However, I would be willing to vote for the agreement if the president takes steps to strengthen it in the coming weeks through pro-trade modifications in the implementing legislation.”
Lori Wallach, director of Public Citizen’s Global Trade Watch and a longtime critic of free-trade pacts, said that Mr. Trump and Democrats could reach a deal next year to ensure passage of the agreement but that it would need to go further to address labor, environmental and outsourcing concerns.
“Of course, who knows what lunatic things unrelated to trade that Donald Trump might do in the meantime to derail that prospect,” she said.