WASHINGTON — The Trump administration announced on Monday that it would impose new tariffs on Canadian softwood lumber imports, escalating a longstanding conflict with America’s second-largest trading partner.

The Commerce Department determined that Canada had been improperly subsidizing the sale of softwood lumber products to the United States, and after failed negotiations, Washington decided to retaliate with tariffs of 3 percent to 24 percent. The penalties will be collected retroactively on imports dating back 90 days.

The decision came days after President Trump complained bitterly about Canada’s dairy trade practices, and the tariffs signaled a harsher turn in his relationship with Canada, even as he seeks to renegotiate the North American Free Trade Agreement. While he has often assailed China, Mexico and others for their trade practices, he seemed to have forged a strong relationship with Canada’s prime minister, Justin Trudeau.

The United States and Canada have been at odds over softwood lumber in one form or another since the 19th century, with the current dispute tracing back to 1982. The United States imported $5.7 billion in softwood lumber last year alone, mainly for residential home building.