The trick is learning how to hold on to consciousness while still allowing your mind to drift towards sleep. You do this by gradually weakening the strength of your consciousness. If you weaken it too much and too quickly you lose it completely and then fall asleep. If you don't weaken it enough your mind can't drift towards sleep.

Here's a metaphor I put together to help describe the process.
http://www.dreamviews.com/f79/zen-art-wild-127113/