The ruling was backed by five of the court's six conservative justices. US President Donald Trump praised the decision in a post on his Truth Social platform.