(CNN) Canada agreed late Sunday to sign on to a trade deal between the United States and Mexico, revamping the three-country North American Free Trade Agreement after more than a year of tortuous negotiations.

Just hours before a midnight deadline, the US and Canadian governments agreed to a deal that would allow US farmers greater access to Canada's dairy market and address concerns about potential US auto tariffs, officials from both countries said.

The agreement with Canada and Mexico — two of the United States' biggest trading partners — fulfills President Donald Trump's campaign pledge to renegotiate NAFTA and avoids his threat to exclude Canada if the talks failed.

The new deal has a new name: the United States-Mexico-Canada Agreement.

"It will strengthen the middle class, and create good, well-paying jobs and new opportunities for the nearly half billion people who call North America home," said US Trade Representative Robert Lighthizer and Canadian Foreign Affairs Minister Chrystia Freeland in a joint statement.

Read More