Chief Justice John Roberts and the court’s three liberal justices joined with Justice Brett Kavanaugh in the 5-4 vote.