The ruling marked a loss for a legal team that included former Trump administration official Ken Cuccinelli.