Republicans have pledged to appeal the ruling to the US Supreme Court with only months until the midterm elections.