Answers.Body: <p>Yes, you can, as long as the king doesn't pass through or end up on an attacked square.</p>
  <p>From <a href="//handbook.fide.com/chapter/E012018" rel="noreferrer">FIDE Laws of Chess</a>:</p>
  <blockquote>
  <p><strong>3.8.2.1</strong>   The right to castle has been lost:<br />
             
  <em>3.8.2.1.1</em>   if the king has already moved, or<br />
             
  <em>3.8.2.1.2</em>   with a rook that has already moved.</p>
  <p><strong>3.8.2.2</strong>   Castling is prevented temporarily:<br />
             
  <em>3.8.2.2.1</em>   if the square on which the king stands, or the square which it must cross, or the square which it is to occupy, is attacked by one
  or more of the opponent's pieces, or<br />
             
  <em>3.8.2.2.2</em>   if there is any piece between the king and the rook with which castling is to be effected.</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2012-05-02T12:59:11.543Z
Answers.Text: That was interesting, your answer changed from NO to YES!
Answers.UserDisplayName: Binoj Antony
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2012-05-05T13:59:07.353Z
Answers.Text: We should ask Viktor Korchnoi!
Answers.UserDisplayName: Tony Ennis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-04T22:38:16.773Z
Answers.Text: To explain Tony Ennis' joke, in 1974, Korchnoi was playing Karpov in the Candidates final for the right to challenge Fischer.  Midgame, Korchnoi strolls over to the arbiter O'Kelly de Galway, and asks if he can castle while his rook is attacked.  O'Kelly looks at him stunned, but answers yes.  "It had never come up before," Viktor shrugged.
Answers.UserDisplayName: A passerby
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-04T21:46:33.360Z
Answers.Text: Does that mean that there should be no piece (of any color) between unmoved king and rook (to be castled)?
Answers.UserDisplayName: Sufyan Naeem
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-11T15:36:13.580Z
Answers.Text: I was surprised by the Korchnoi story, but according to [this article from the South Florida _Sun-Sentinel_](https://www.sun-sentinel.com/news/fl-xpm-1995-07-16-9507110283-story.html), the story appears in Korchnoi's memoir _Chess is My Life_.
Answers.UserDisplayName: Mark Dominus
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2012-05-02T12:45:43.623Z
Answers.LastActivityDate: 2022-01-07T10:28:36.587Z
Answers.LastEditDate: 2022-01-07T10:28:36.587Z
Answers.UserDisplayName: Philip Seyfi
Answers.Body: <p>One nice example of this is in <a href="//www.chessgames.com/perl/chessgame?gid=1104131" rel="noreferrer">this game</a>, where a player named Feuer takes advantage of the ability to castle queenside while b1 is attacked to play a beautiful combination.</p>
  
  <pre><code>[FEN ""]
  [Event "Belgian Championship"]
  [Site "Liege BEL"]
  [Date "1934"]
  [EventDate "?"]
  [Round "?"]
  [Result "1-0"]
  [White "Otto Feuer"]
  [Black "Alberic O'Kelly de Galway"]
  [ECO "C73"]
  [WhiteElo "?"]
  [BlackElo "?"]
  [PlyCount "25"]
  
  1.e4 e5 2.Nf3 Nc6 3.Bb5 a6 4.Ba4 d6 5.Bxc6+ bxc6 6.d4 f6 7.Nc3
  Rb8 8.Qd3 Ne7 9.Be3 Rxb2 10.dxe5 fxe5 11.Nxe5 dxe5 12.Qxd8+
  Kxd8 13.O-O-O+ 1-0
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2012-07-18T20:44:32.487Z
Answers.LastActivityDate: 2020-03-10T08:54:22.927Z
Answers.LastEditDate: 2020-03-10T08:54:22.927Z
Answers.UserDisplayName: David Spencer
Answers.Body: <p>The rules are that the king can't castle <em>into</em> check, <em>through</em> check, or when <em>in</em> check. This applies to the king's square, plus the two squares to the right or left.</p>
  
  <p>Castling is permitted when the <em>rook</em> is under attack (on the rook's square). On the queen side, that would also include the knight's square. But not on the kingside, because the king would be castling <em>into</em> check. He also can't castle if the bishop's or queen's square is under attack. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2012-05-02T13:38:20.823Z
Answers.LastActivityDate: 2012-06-12T01:43:50.513Z
Answers.LastEditDate: 2012-06-12T01:43:50.513Z
Answers.UserDisplayName: Tom Au
Answers.Body: <p>There is more on the condition to consider
  The King and Rook have to be on the same rank, otherwise Pam-Krabbe castling would be possible.
  Pam-Krabbe castling is basically a vertical castling, where the king would castle with a promoted pawn. This is not allowed anymore. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-16T10:52:56.443Z
Answers.LastActivityDate: 2020-01-16T13:24:25.087Z
Answers.LastEditDate: 2020-01-16T13:24:25.087Z
Answers.UserDisplayName: d4zed
Answers.Body: <p>Here is a problem that I published in the <a href="http://matplus.net/start.php?px=1608213940&amp;app=forum&amp;act=posts&amp;fid=xshow2&amp;tid=2297" rel="nofollow noreferrer">MatPlus.net forums</a> a few months ago. It demonstrates how the rook can move through squares that are attacked. The squares a1 and b1 are maximally guarded. If it were on a board, it would definitely frustrate a few people, which is the exact point of this little exercise!</p>
  <pre><code>[Title &quot;me, Matplus.net Forum 5/24/2019, Mate In 2&quot;]
  [FEN &quot;8/8/8/8/pppbbp1r/nr2pppB/q2n2Pp/R3K2k w Q - 0 1&quot;]
  
  1. O-O-O+! Nf1 2. Rxf1#
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-15T02:03:31.423Z
Answers.LastActivityDate: 2021-05-02T15:02:52.163Z
Answers.LastEditDate: 2021-05-02T15:02:52.163Z
Answers.UserDisplayName: Rewan Demontay
Answers.Body: <p>Yes, if the rook is threatened, you may still castle. The threatened squares rule only applies to squares where the king passes (starting and final position included).</p>
  
  <p>For example, in the case of white castling queenside, for instance, a threat to <code>a1</code> or <code>b1</code> does not prevent the castle from taking place.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-15T16:27:35.857Z
Answers.Text: Think of the reasoning being that the king cannot be in check, even if temporarily while castling, but the rook has no such restriction.
Answers.UserDisplayName: PhishMaster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2012-05-02T12:52:50.297Z
Answers.LastActivityDate: 2013-08-06T23:48:15.200Z
Answers.LastEditDate: 2013-08-06T23:48:15.200Z
Answers.UserDisplayName: James Tomasino
Body: <p>Is castling possible if any of the squares involved in the castling are under attack, or is this a problem only if the squares moved through by the king are under attack and not the ones moved through by the rook?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2012-05-02T12:55:00.427Z
Comments.Text: +1 because it is a very common mistake among new players.
Comments.UserDisplayName: Hugo Sereno Ferreira
Tags: <rules><kings><castling><rooks><check>
Title: When is castling possible?
ThreadText: # When is castling possible?
  
  (Asked by: username_0 on 2012-05-02)
  
  Is castling possible if any of the squares involved in the castling are under attack, or is this a problem only if the squares moved through by the king are under attack and not the ones moved through by the rook?
  
  **Tags:** rules, kings, castling, rooks, check
  
  > **Comments:**
  > **username_1**: +1 because it is a very common mistake among new players.  
  
  ---
  
  ## 6 answers
  
  ### Answer by username_11 on 2012-05-02. Score: 54 | Accepted answer
  
  Yes, if the rook is threatened, you may still castle. The threatened squares rule only applies to squares where the king passes (starting and final position included).
  
  For example, in the case of white castling queenside, for instance, a threat to `a1` or `b1` does not prevent the castle from taking place.
  
  > **Comments:**
  > **username_12**: Think of the reasoning being that the king cannot be in check, even if temporarily while castling, but the rook has no such restriction.  
  
  ---
  
  ### Answer by username_2 on 2012-05-02. Score: 82
  
  Yes, you can, as long as the king doesn't pass through or end up on an attacked square.
  
  From [FIDE Laws of Chess](//handbook.fide.com/chapter/E012018):
  
  > **3.8.2.1** The right to castle has been lost:  
  >            
  > *3.8.2.1.1* if the king has already moved, or  
  >            
  > *3.8.2.1.2* with a rook that has already moved.
  >
  > **3.8.2.2** Castling is prevented temporarily:  
  >            
  > *3.8.2.2.1* if the square on which the king stands, or the square which it must cross, or the square which it is to occupy, is attacked by one
  > or more of the opponent's pieces, or  
  >            
  > *3.8.2.2.2* if there is any piece between the king and the rook with which castling is to be effected.
  
  > **Comments:**
  > **username_0**: That was interesting, your answer changed from NO to YES!  
  > **username_3**: We should ask Viktor Korchnoi!  
  > **username_4**: To explain username_3 username_3' joke, in 1974, Korchnoi was playing Karpov in the Candidates final for the right to challenge Fischer.  Midgame, Korchnoi strolls over to the arbiter O'Kelly de Galway, and asks if he can castle while his rook is attacked.  O'Kelly looks at him stunned, but answers yes.  "It had never come up before," Viktor shrugged.  
  > **username_5**: Does that mean that there should be no piece (of any color) between unmoved king and rook (to be castled)?  
  > **username_6**: I was surprised by the Korchnoi story, but according to [this article from the South Florida _Sun-Sentinel_](https://www.sun-sentinel.com/news/fl-xpm-1995-07-16-9507110283-story.html), the story appears in Korchnoi's memoir _Chess is My Life_.  
  
  ---
  
  ### Answer by username_7 on 2012-07-18. Score: 31
  
  One nice example of this is in [this game](//www.chessgames.com/perl/chessgame?gid=1104131), where a player named Feuer takes advantage of the ability to castle queenside while b1 is attacked to play a beautiful combination.
  
  ```
  [FEN ""]
  [Event "Belgian Championship"]
  [Site "Liege BEL"]
  [Date "1934"]
  [EventDate "?"]
  [Round "?"]
  [Result "1-0"]
  [White "Otto Feuer"]
  [Black "Alberic O'Kelly de Galway"]
  [ECO "C73"]
  [WhiteElo "?"]
  [BlackElo "?"]
  [PlyCount "25"]
  
  1.e4 e5 2.Nf3 Nc6 3.Bb5 a6 4.Ba4 d6 5.Bxc6+ bxc6 6.d4 f6 7.Nc3
  Rb8 8.Qd3 Ne7 9.Be3 Rxb2 10.dxe5 fxe5 11.Nxe5 dxe5 12.Qxd8+
  Kxd8 13.O-O-O+ 1-0
  
  ```
  
  
  ---
  
  ### Answer by username_8 on 2012-05-02. Score: 22
  
  The rules are that the king can't castle *into* check, *through* check, or when *in* check. This applies to the king's square, plus the two squares to the right or left.
  
  Castling is permitted when the *rook* is under attack (on the rook's square). On the queen side, that would also include the knight's square. But not on the kingside, because the king would be castling *into* check. He also can't castle if the bishop's or queen's square is under attack.
  
  
  ---
  
  ### Answer by username_9 on 2020-01-16. Score: 2
  
  There is more on the condition to consider
  The King and Rook have to be on the same rank, otherwise Pam-Krabbe castling would be possible.
  Pam-Krabbe castling is basically a vertical castling, where the king would castle with a promoted pawn. This is not allowed anymore.
  
  
  ---
  
  ### Answer by username_10 on 2019-09-15. Score: 0
  
  Here is a problem that I published in the [MatPlus.net forums](http://matplus.net/start.php?px=1608213940&app=forum&act=posts&fid=xshow2&tid=2297) a few months ago. It demonstrates how the rook can move through squares that are attacked. The squares a1 and b1 are maximally guarded. If it were on a board, it would definitely frustrate a few people, which is the exact point of this little exercise!
  
  ```
  [Title "me, Matplus.net Forum 5/24/2019, Mate In 2"]
  [FEN "8/8/8/8/pppbbp1r/nr2pppB/q2n2Pp/R3K2k w Q - 0 1"]
  
  1. O-O-O+! Nf1 2. Rxf1#
  
  ```
  
  
  ---
  
  