Castling is a special move in chess that uses both a rook and the king . In castling , the king is moved two squares toward the rook , and the rook moves past the king to the square right next to where the king has moved . In chess problems , castling is assumed to be allowed if it appears possible , unless it can be proved by retrograde analysis that either the king or chosen rook has previously moved .