Castling is the only time in the game when more than one piece may be moved during a turn. Castling can only occur if there are no pieces standing between the king and the rook. Neither king nor rook may have moved from its original position. There can be no opposing piece that could possible capture the king in his original square (you cannot castle while you are in check), the square he moves through, or the square that he ends the turn (you cannot castle into check). Castling was invented around the 1500s to speed up the game. In 1561, a book by Ruy Lopez published in Spain mentioned that castling took two moves. You had to play the rook to king’s bishop one square on one move, then the king to king’s knight one on the next move. At the time, castling seem to be in one move in Italy and France. Up until the mid 19th century, some rules of chess allowed you to castle, followed by moving the h pawn to h3 (pawn to king’s rook three). The verb castle (to castle) first appeared in a book by Beale in 1656. Earlier words for castling included exchange, change, leap, or shift. The record for the latest castling seems to be on move 48.
In this diagram, white castles on kingside while black castles on queenside
When there are pieces between the king and the rook, the player cannot castle, as shown in this diagram:
Also, when the king is in check or the path is under attack, castling cannot be done, as in the following situation: