user8527: A quote from Wikipedia for castling rule:

the squares between the king and the rook involved are unoccupied

What if the squares are not occupied at this instance but an opponent piece was there before?  
I tried on a computer chess game, it would not allow a castling move.  

user7500: FIDE Article 3.8:

(1) The right to castle has been lost:

if the king has already moved, or
with a rook that has already moved.

(2) Castling is prevented temporarily: 

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
if there is any piece between the king and the rook with which
  castling is to be effected.


The fact that a enemy piece previously occupied a square between the king and rook does not make castling illegal. Instead, there is probably some other reason why castling is not permitted.

8527: <p>A quote from Wikipedia for castling rule:</p>

<blockquote>
  <p>the squares between the king and the rook involved are unoccupied</p>
</blockquote>

<p>What if the squares are not occupied at this instance but an opponent piece was there before?  </p>

<p>I tried on a computer chess game, it would not allow a castling move.  </p>
 7500: <p>FIDE Article 3.8:</p>

<blockquote>
  <p>(1) The right to castle has been lost:</p>
  
  <ul>
  <li><p>if the king has already moved, or</p></li>
  <li><p>with a rook that has already moved.</p></li>
  </ul>
  
  <p>(2) Castling is prevented temporarily: </p>
  
  <ul>
  <li><p>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</p></li>
  <li><p>if there is any piece between the king and the rook with which
  castling is to be effected.</p></li>
  </ul>
</blockquote>

<p>The fact that a enemy piece previously occupied a square between the king and rook does not make castling illegal. Instead, there is probably some other reason why castling is not permitted.</p>
