(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.
Negotiators from the three countries spent all weekend working over the phone, hoping to keep the nearly 25-year-old deal alive.
Earlier in the evening, Trump was briefed on the nearly finalized negotiations by Lighthizer and White House adviser Jared Kushner.
The Trump administration plans to send the new deal to Congress, starting a 60-day review period before Trump can sign it. Congress can suggest changes during that time.
Ahead of the weekend's talks, several lawmakers had warned that they would not support a deal without Canada.
"It would be a monumental mistake to do this without Canada," US Senator Ron Wyden of Oregon, the top Democrat on the Senate committee that oversees trade, said Friday, before the text was delivered. "It's basically surrendering on fixing NAFTA."
The Trump administration has been working to sign a new trade deal before Mexican President Enrique Peña Nieto leaves office on December 1. To meet that deadline, the text of the agreement had to be submitted to Congress before October.
Negotiators from the three countries began talks about updating NAFTA more than a year ago. Trump had campaigned on ripping up the trade pact, calling it "the worst deal maybe ever signed."
In August, the United States and Mexico resolved an issue over auto manufacturing, but several sticking points with Canada remained. Trump wanted Canada to open its dairy market to US farmers, and Canada wanted to preserve a mechanism for resolving disputes.
Those goals were achieved in the deal reached late Sunday, according to a Canadian official with knowledge of the negotiations.
The access to Canada's dairy market will closely mirror what was given under recently negotiated agreements between Canada and the European Union and a separate one with Pacific countries, the Canadian official said.
Canada and Mexico are the United States' second and third largest trading partners after China. A deal that left one of them out could cause chaos for businesses that rely on imports.
The US Chamber of Commerce has said it would be "unacceptable to sideline Canada, our largest export market in the world."
Vehicles, machinery and agricultural products make up much of the goods traded between the countries.