Sets the operation to be performed on the stencil buffer values if the compare function was not successful. Note that this takes place before depth testing.
This is one of the most useful things stencils can do - not render something to the screen and then allow you to draw with the shape it would have been if it had rendered.
You can see in the output screenshot that a partially obscured entity will still write its entire shape to the stencil buffer.
From Lex's Stencil Tutorial.