The ruling comes as a decisive legal setback to a trade policy that had redrawn global supply chains and strained ties with key trading partners