The present work investigates the gravitational collapse of a perfect fluid in $f(R)$ gravity models. For a general $f(R)$ theory, it is shown analytically that a collapse is quite possible. The singularity formed as a result of the collapse is found to be a curvature singularity of shell focusing type. The possibility of the formation of an apparent horizon hiding the central singularity depends on the initial conditions.