Can You Castle Out of Check?

No. You cannot castle while your king is in check, nor can you castle through or into a square that's under attack — but once you've dealt with the checking piece on a later move, castling is fair game again.

r . . . k . . r
p p p q . p p p
. . n p . n . .
. . b . p . . .
. . B . P . . .
. . N P . N . .
P P P Q . P P P
R . . . K . Q R
Black's king is not in check here, so both sides retain castling rights — but the rule matters the moment a check appears.

Castling rules trip up even experienced players in the heat of a game — practice spotting them for free against Chessy's adaptive engine.

Play free against the Chessy engine →

The three castling restrictions

Castling has more conditions than most beginners realize. Beyond the familiar rule that the king and rook must not have moved, and that no pieces sit between them, there are three situations that block castling outright: you cannot castle out of check (your king is currently attacked), through check (the square the king passes over is attacked), or into check (the destination square is attacked). Any one of these stops the move, even if everything else about the position looks legal.

Why the rule exists

Castling is meant to tuck the king to safety in one move, not to dodge an active threat for free. If you could castle out of check, a king under direct attack could simply hop two squares away and grab a rook's protection in the same turn — effectively getting two king moves' worth of safety at once. Blocking it keeps the response to check consistent: you must move the king normally, block the check, or capture the checking piece.

What you can do instead

If you're in check, your options are the same three every player learns first: move the king off the checked square, block the check with another piece (if it's a sliding piece giving the check), or capture the piece giving check. Castling isn't one of the choices in that moment. Once the check is resolved and no piece has moved from the king or rook involved, you keep the right to castle on a future move — the check doesn't permanently forfeit it.

Frequently asked questions

Can you castle to escape check?

No. Castling is not a legal response to check, even though it moves the king. You must move the king elsewhere, block, or capture the attacker instead.

Can you castle if the rook's square is attacked?

Yes — only the king's start, path, and landing squares matter for the 'through/into check' rule. An attacked rook square doesn't block castling.

Do you lose castling rights permanently after being checked?

No. Being in check only blocks castling on that specific move. As long as the king and rook still haven't moved, you can castle later once the check is gone.

Can you castle through a square attacked by a pinned piece?

Yes. What matters is whether the square is currently attacked, not whether the attacking piece could legally capture there. A pinned attacker still counts as attacking the square.