According to current theory in the sports science literature (as of 1997), skeletal muscle cramps during exercise probably happen when muscles that are shortened (for example, a calf muscle when your toe is pointed) are repeatedly stimulated. This can happen if your foot is extended, toe pointed, and you keep extending it further. You can actively do this by, for example, running on your toes or doing lots of toe-raises without going down to extend the muscle. What appears to happen is that the muscle gets fatigued, and it doesn't relax well. There is a reflex arc -- made up of the muscle, the nerves carrying signals to the central nervous system (CNS) and the nerves carrying signals from the CNS back to the muscle -- that keeps carrying contraction signals from and to the muscle. This appears to lead to a sustained contraction in the muscle, also known as a cramp.
A blurb from here: