How to Castle in Chess
Castling is the only move that shifts two pieces at once. You tuck the king off the open center and bring a rook toward the middle in a single turn. Club games are often decided by who castles with a plan, and who castles into a pawn storm that was already prepared.
The four conditions
Both the king and that rook must still be on their starting squares. Nothing may stand between them. The king cannot be in check, and it cannot pass through or land on a square the opponent attacks. You may castle to get out of a threat only if the path itself is safe. A rook may legally cross an attacked square. The king may not.
Kingside castling is written O-O. The king steps from e1 to g1 and the rook from h1 to f1. Queenside castling is O-O-O: the king goes from e1 to c1 and the rook from a1 to d1. Black uses the same letters on rank 8.
Kingside or queenside
Kingside castling is usually faster. The king only moves one square, and the pawn shield on f, g, and h is often still intact. Queenside castling takes one extra square for the king, and the a-pawn has often already moved, so the king on c1 sits nearer an open file.
Queenside castling has a different strength. The rook lands on d1, already on a central file. In a Queen's Gambit or a 1.d4 opening, that rook immediately backs the d-pawn. In a sharp Sicilian, White often castles queenside on purpose so the kings stand on opposite wings and both sides can push pawns without exposing their own king.
When to wait one move
Castling is not a tax you pay on move 8. Wait when the opponent's pieces already point at the wing you want. A bishop on the a2–g8 diagonal, a queen on the h-file, and a knight ready for g5 is a reason to look at the other wing, or to interpose a developing move first.
Also wait when castling walks into a pin. In the Italian Game after 1.e4 e5 2.Nf3 Nc6 3.Bc4 Bc5 4.c3 Nf6 5.d3, Black is happy to castle kingside once the f7-pawn is defended. White should not castle and then immediately play a move that opens the diagonal into g1.
The useful habit is a two-question check before you castle: which of my pieces still sit on the back rank, and which file will open next? If the answer is "their pawn break hits the king I am about to hide," spend the tempo on development or on stopping that break.
Opposite-side castling
When the kings live on different wings, pawn moves in front of your own king are no longer weakening in the same way. They are the attack. The side that opens a file first, with pieces already aimed at the enemy king, usually lands the first real threat. Do not start the pawn storm until your minor pieces are out. A race with two undeveloped pieces is a race you are running alone.
Frequently Asked Questions
Can I castle if my rook is attacked?
Yes. The rook is allowed to start on an attacked square and to cross an attacked square. The restriction applies only to the king.
Can I castle out of check?
No. You must answer the check with a king move, a capture, or an interposition. Castling is not one of those answers while the king is in check.
Can I castle on both sides in one game?
No. After you castle once, the king has moved. The other rook can still move, but castling is no longer legal.
Castle with a reason
Learn the legal test until it is automatic, then choose the wing that matches the pawn structure. The full piece rules sit in the rules of chess, and the middlegame consequences are in king safety in the middlegame. When a castling square looks suspicious, check it with chess hints before you commit the king.
Try the line on the board with chess hints.