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 trade agreement governing hundreds of billions of dollars in commerce that underpins their mutually dependent 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 of Canada 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.
But Mr. Trump faces a daunting challenge at home, where Congress must approve the deal before it can take effect.
The complicated politics of trade would have made the task formidable enough even before the midterm elections, but it will grow only more so once Democrats assume control of the House in January.
Some pro-trade lawmakers complain that the revised agreement puts too many limits on the free flow of goods and services across borders, while trade skeptics maintain that it does not do enough to safeguard American jobs, encourage higher wages and protect the environment.
Submission to Congress will open a frenzy of fresh negotiations over legislation to enact the agreement, potentially unraveling the careful balance achieved with Mexico and Canada.
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. He signaled as late as Friday that he may reach an understanding with Mr. Xi during a dinner to forestall such a move.
The agreement with Canada and Mexico is 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 after months of rancorous talks that raised doubts about whether any accord was possible. Mr. Trump repeatedly assailed his counterparts and threatened to scrap Nafta altogether.
The appearance of the three leaders side by side in Buenos Aires to attend an economic summit meeting of the Group of 20, or G-20, was meant to paper over the bitterness, but the hard feelings were still evident.
“We worked hard on this agreement,” Mr. Trump said. “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.”
Stoic and unmoved, 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. 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 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 was not as much of a transformation as Mr. Trump has suggested, 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.
Whether Mr. Trump can reach across the aisle to sell it to Congress remains an open question. In nearly two years in office, he has made little effort to forge bipartisan consensus in Congress, as Republicans controlled both chambers.
But trade muddies the usual partisan lines, with free traders and skeptics of globalization in both parties, and the dynamics were further complicated by the announcement this week by General Motors that it will eliminate 14,000 jobs and idle five plants in the United States and Canada.
Mr. Trump played down the challenge on Friday, expressing confidence that he would easily win approval by Congress.
“It’s been so well reviewed, I don’t expect to have very much of a problem,” he said.
Business groups and some Republicans praised the agreement and called for expeditious endorsement by lawmakers. “I believe it will create more jobs and expand economic opportunities for American workers, farmers and manufacturers by leveling the playing field on trade,” said Senator Rob Portman, Republican of Ohio.
But 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.”