Some believe this is because you are losing consciousness too fast, and so it is the body's way of moderating this. Others believe it is just because of stress, caffeine use, or strenuous activities during the day.
This is only problematic if it causes a cycle or causes anxiety about falling asleep. If you are startled awake because of the jerking, then you may become fatigued and worried about going asleep, thus increasing the chances this will happen, and increasing the sense of dread.
At any rate, this seems to be normal, and you should not worry about it. Just relax and continue trying to get to sleep.
Chat with our AI personalities
They say it could be because of neurons expressed extra neurotransmitters as your body goes into the paralyzed state of sleep (keeps you from acting out your dreams and keeps you still). There are different stages of sleep and the twitching usually occurs in the first few stages. Relax. Many people also say that have been "jolted" awake. This has been an Andy @ Jason answer
While your falling asleep, your muscles continue to slowly relax, until you reach REM sleep and your body is effectively paralyzed (called REM Atonia). While you are in the pre-sleep stage, sometimes your brain becomes aware that it is falling asleep, and tries to wake up. When this happens, your brain tries to regain the use of your limbs, so you might feel a sudden shock while your legs twitch. On a related note, some people have a condition where they have trouble relaxing their muscles and can't sleep, which is called Restless Leg Syndrome.
About 70% of people experience this as they fall asleep. The muscles suddenly contract and usually cause people to wake up. This phenomenon is called hypnic jerk. The cause remains unknown.