Can You Castle Out of Check?

Castling is the only move in chess where two pieces move at once: the king steps two squares towards a rook, and the rook jumps over to the other side of the king. It comes with a short list of conditions, and two of them confuse almost everyone at first.

Short answer: no, you cannot castle while your king is in check. You also cannot castle through a square that is attacked, or into check. You can castle if your king was checked earlier in the game, as long as it never moved.

All castling rules

  1. The king has not moved yet in this game.
  2. The rook has not moved yet (castling with the other rook is still allowed if only one rook moved).
  3. All squares between the king and the rook are empty.
  4. The king is not in check right now.
  5. The king does not pass through a square attacked by an enemy piece.
  6. The king does not end up in check.

That is all. Notice what is not on the list: the rook may be attacked, and on the queenside the b-file square next to the rook may be attacked, because the king never crosses it.

You cannot castle out of check

The black rook on e8 gives check. White would love to castle to safety, but the rules say no: escape the check first with a normal king move, a block or a capture.

Chess diagram: white king on e1 in check from a black rook on e8; the legal king moves do not include castling
In check: the dots show normal king moves only. No castling.

You cannot castle through check

Now the king is not in check, but the black rook on f8 attacks f1, the square the king would cross on its way to g1. Kingside castling is illegal.

Chess diagram: black rook on f8 attacks f1, so the white king on e1 cannot castle kingside
f1 is attacked, so O-O is not allowed (and Kf1 itself is illegal too).

You can castle when the rook is attacked

Here the black rook on h8 attacks the white rook on h1. Many beginners think this stops castling. It does not: only the king's path matters.

Chess diagram: black rook on h8 attacks the white rook on h1, but White can still castle kingside to g1
The rook is attacked, yet castling (the dot on g1) is legal.

Queenside: b1 may be attacked

When castling queenside the king goes from e1 to c1, crossing d1. The rook passes over b1, but the king never touches it, so an attack on b1 does not matter.

Chess diagram: black rook on b8 attacks b1, but White can still castle queenside, the king moving from e1 to c1
b1 is attacked, but O-O-O (the dot on c1) is still legal.

How to castle on a touch screen

Move the king two squares towards the rook: tap the king, then tap g1 (kingside) or c1 (queenside). The rook jumps over automatically. On this site's board, castling only appears as an option when it is legal.

Questions

Can you castle after being in check earlier?

Yes. Being checked earlier does not matter, as long as the king did not move to get out of it (blocking or capturing the checking piece keeps castling rights).

Can you castle if the king moved and came back?

No. Once the king has moved, castling is gone for the rest of the game, even if it returns to its starting square.

Can you castle with a promoted rook?

No. Castling is only possible with a rook that has stood on its original square since the start and never moved.

Can you castle twice?

No. Each player can castle at most once per game.

Try it on a real board: free, no sign-up, set up in seconds.

♟ Play a two-player game