The ruling is seen as a test of President Donald Trump’s “America First” pledge.