US, Canada reach agreement on new trade deal President Trump had sparred with Prime Minister Trudeau for months.

The U.S. and Canada reached an agreement on a new trade deal late Sunday after months of often testy back-and-forth between President Donald Trump and Canadian Prime Minister Justin Trudeau. The U.S. had previously negotiated a deal with Mexico in late August.

The new deal would replace the North American Free Trade Agreement (NAFTA), which has long been derided as unfair to the United States by Trump, should it be approved by Congress.

"Today, Canada and the United States reached an agreement, alongside Mexico, on a new, modernized trade agreement for the 21st Century: the United States-Mexico-Canada Agreement (USMCA)," the U.S. and Canada said in a joint statement Sunday. "USMCA will give our workers, farmers, ranchers, and businesses a high-standard trade agreement that will result in freer markets, fairer trade and robust economic growth in our region."

Trump hailed the deal Monday morning on Twitter, calling it a "a wonderful new Trade Deal" and saying, "Congratulations to Mexico and Canada."

A Canadian official told The Associated Press that the agreement preserves a NAFTA dispute-resolution process that the U.S. wanted to jettison.

The official also said it exempts tariffs on 2.6 million cars and on diary it preserves supply management in Canada, the AP reported.

"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," the two countries' joint statement said.

The deal will still need to win approval by Congress, which could be further complicated if Democrats win control of the House or Senate in this year's midterm elections.

"It’s a good day for Canada," Trudeau told reporters leaving his office Sunday night. He also tweeted about the agreement just before midnight.

Trump has targeted Trudeau for criticism since a messy appearance at the G7 in Canada in June prior to his trip to Singapore for a summit with North Korean leader Kim Jong Un. Trump imposed tariffs on metal goods from Canada starting on June 1, and criticized Trudeau as "meek and mild" from Air Force One while leaving the G7.

As recently as Wednesday at the U.N. General Assembly Trump spoke harshly of the prime minister. He admitted he refused to meet with Trudeau one-on-one.

"His tariffs are too high, he doesn't seem to want to move and I've told him forget about it," Trump said at a freewheeling press conference. "And frankly we're thinking about just taxing cars coming in from Canada, that's the mother load, that's the big one. We're very unhappy with the negotiations and the negotiating style of Canada."

Trump continued, "Canada has treated us very badly, they've treated our farmers in Wisconsin and New York state, and a lot of other states -- very badly. Dairy products, 300 percent -- 300 percent. How do you sell a dairy product at 300 percent? The answer is you don't."

The president has slammed NAFTA dating back to his presidential campaign.

"I don't like NAFTA, I never liked it," Trump said Wednesday. "It's been very bad for the United States, it's been great for Canada, it's been great for Mexico -- very bad for us."