If you were just drifting off to sleep and this happened, it was because your blood pressure was dropping into the relaxed sleep state. This is often accompanied by dreams of tripping or falling, from which you jerk awake suddenly.
I may be wrong, but I believe this is sleep paralysis. If you feel like you're falling or something and can't move for a second, then subconsciously jerk and can freely move again, that should be what it is. It happens if you are conscious (even partially) but your body tries to go to sleep anyways.
The feeling of jerking awake just as sleep begins to overtake us is familiar to most readers. So too is seeing someone in a deep sleep eerily (or adorably) twitching their hands or feet. What is it that makes people do this while they are supposed to be resting? Medical science has come up with an official sounding word for twitching: myoclonus. I'm sure we all feel more secure already. Unfortunately, there's not a lot of data on why exactly we experience sleep myoclonus. Since it happens spontaneously in normal sleepers, and they aren't likely to complain, it's tough to study under normal circumstances. Doctors usually only get involved when the twitching has gotten so bad that it's keeping people awake. In these cases, it can be a sign of early brain disorders (like Parkinson's or Alzheimer's), an indication of a severe head or nerve injury, or a symptom of fibromyalgia. These imply that twitching is the result of crossed wires between the conscious brain and unconscious motion of the body.