President Rodrigo Duterte of the Philippines lashed out at Canada this week, provoked by a dispute between the nations that has festered for half a decade, over hundreds of tons of Canadian trash brought to Philippine ports.

“Canada, I want a boat prepared. I’ll give a warning to Canada, maybe next week, that they better pull that thing out or I will set sail,” he said at a news conference in San Fernando city in the Philippines on Tuesday.

He added: “We will declare war against them.”

In the days following Mr. Duterte’s remarks, Canada’s government responded, saying, in effect, that it was working on resolving the dispute — a business transaction gone wrong that has spiraled outward over the years and now touches on not only Philippine-Canadian relations, but also on an international treaty and Canada’s reputation abroad.

The trash in question arrived in 2013 and 2014, in 103 containers delivered from Canada by a private company and marked — falsely, Philippine officials say — as holding recyclable plastic scrap. In reality, dozens of containers held used adult diapers, household garbage, plastic bags and other waste, and some of the containers were found to be “leaching fluids,” according to a legal opinion on the case by the Pacific Centre for Environmental Law and Litigation, a Canadian nonprofit.