MANILA — The Canadian government said on Wednesday that it would take back tons of garbage sent to the Philippines several years ago, after President Rodrigo Duterte ordered that it be returned immediately.

In a statement, Catherine McKenna, the Canadian minister of environment and climate change, said a Canadian company had been awarded a contract to repatriate the trash.

“Canada values its deep and longstanding relationship with the Philippines and has been working closely with Filipino authorities to find a solution that is mutually acceptable,” she said.

The company, Bolloré Logistics Canada, is to begin preparations for shipping in the coming days, with the removal expected to be completed by the end of June, the Canadian government said. Canada is paying all the costs.