The ruling from the bench came in a case led by Oregon and a coalition of 20 other states and the District of Columbia.