One way this can be done, is using the render layers mask layers. While this may not be as simple as Denis's answer, it's always good to know more than one way to do something, and it can be a bit more flexible because it works with both cycles and BI (and should work with basically any other rendering engine also).
Using Mask Layers
To create a mask layer, move your object(s) to their own layer. Generally you want this layer to be a bit out of the way. I've highlighted in a few common choices, but of coarse, you can use whatever layer you want to.
Then, to use that layer as a mask, simply highlight it in the mask layers layer group.
This effect is really useful for a lot of things, including VFX, and advanced compositing, but my favorite use, is to make something appear bigger on the inside:
How can I create a portal?