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.