A muscle cramp occurs when a muscle suddenly becomes forcibly and uncontrollably shortened and locked into a painful spasm. A spasm occurs when a muscle, or even a few fibers of a muscle contracts involuntarily (i.e. without you consciously doing it).