The Trump administration is hitting Canada with stiff tariffs of up to 24% on lumber shipped into the United States.

These are the first tariffs imposed by President Trump, who during his election campaign threatened to use them on imports from both China and Mexico.

The decision on Monday evening is bound to lead to a standoff and could stoke fears of a trade war between the U.S. and Canada, two of the world's largest trade powers.

Commerce Secretary Wilbur Ross said the tariffs, or taxes, announced Monday evening were being imposed after trade talks on dairy products fell through.

"It has been a bad week for U.S.-Canada trade relations," Ross said in a statement.

Related: Buy American, hire American. But Trump won't train America

Trump's tariffs come as the U.S., Canada and Mexico prepare to renegotiate NAFTA, the 1994 free trade agreement. Trump has directed almost all of his NAFTA criticism at Mexico, which makes this decision even more surprising.

When Canadian Prime Minister Justin Trudeau visited Trump in February, Trump said he only expected to be "tweaking" the U.S.-Canada trade relationship.

But his tune changed Tuesday morning.

"Canada has made business for our dairy farmers in Wisconsin and other border states very difficult. We will not stand for this. Watch!" Trump tweeted.

Canada has made business for our dairy farmers in Wisconsin and other border states very difficult. We will not stand for this. Watch! — Donald J. Trump (@realDonaldTrump) April 25, 2017

The tariffs -- also called duties -- ranged from 3% to 24% on five specific Canadian lumber companies. For all other Canadian lumber companies, there's a nearly 20% tariff on exports to the US.

The five firms were: West Fraser Mills, Tolko Marketing and Sales, J.D. Irving, Canfor Corporation, and Resolute FP Canada. West Fraser Mills will pay the highest duty of 24%.

The duties were imposed to create a level playing field for American lumber companies.

U.S. lumber companies allege that Canadian firms are provided with unfair subsidies by the Canadian government.

Canadian exports of softwood lumber to the United States were valued at $5.6 billion last year, according to the Commerce Department.

The Commerce Department said the duties are preliminary and a final determination will be made in September. Ross said during a press conference Tuesday that the tariffs are effective immediately. In fact, they will apply retroactively and duties will will be collected from 90 days ago, when the U.S. administration first warned Canada.

The administration didn't say why they went after five specific firms or why the others had to pay the 20% tariff. The Commerce Department only said the duties were commensurate to the subsidies the companies received from the Canadian government.

Related: America's NAFTA nemesis: Canada, not Mexico

Canadian firms immediately denounced the decision.

"Managed trade only serves to benefit large timber barons in the U.S. while adversely impacting U.S. consumers and millions of hard-working Americans in the housing sector," a spokesperson for Resolute said in a statement. One firm declined to comment and three others didn't immediately respond.

Canadian leaders also criticized the move.

"The government of Canada disagrees strongly with the U.S. Department of Commerce's decision to impose an unfair and punitive duty," Canada's Minister of Foreign Affairs, Chrystia Freeland, and Natural Resources Minister Jim Carr said in a joint statement.

The lumber dispute isn't new, and it's not the first the U.S. has imposed tariffs on Canadian lumber.

In fact, it goes back decades. U.S. lumber companies started alleging in the 1980s that Canadian companies have been unfairly subsidized by their government. In 2002, the U.S. imposed a 30% tariff on Canadian softwood lumber, which Canadian firms claimed cost 30,000 jobs at the time.

Canada has consistently denied it subsidizes its lumber companies. The World Trade Organization sided with Canada in 2004 and the two sides came to a temporary agreement in 2006, which expired last October.

Related: Mexico economy minister warns Trump about tariffs

Despite the agreement, U.S. lumber firms continued to allege that their Canadian counterparts had an unfair advantage which allowed them to sell their lumber in the U.S. market at prices American firms couldn't sell at.

U.S. firms declared victory Monday night.

"Today's ruling confirms that Canadian lumber mills are subsidized by their government and benefit from lumber pricing policies," Cameron Krauss, legal chair for the U.S. Lumber Coalition, said in a statement.

Resolute, the Canadian lumber firm, denied it is subsidized. The Canadian officials called the subsidy allegations "baseless and unfounded."

The move came after there was no breakthrough in U.S. talks on Canadian dairy tariffs. Canada has long taxed U.S. diary products. Some U.S. milk exports, depending on the fat content, face tariffs as high as 292%, according to Canada's Agriculture Department.

The Canadian milk tariffs were grandfathered into NAFTA, one of the few areas of trade where major tariffs still exist.

That could change when Canada, Mexico and the US begin renegotiating NAFTA, a trade deal under pressure in the Trump era.

--Paula Newton contributed reporting to this article