A muscle spasm is a sudden and involuntary contraction of one or more muscles. It can occur in any muscle group in the body and often causes pain or discomfort. Common causes of muscle spasms include dehydration, muscle overuse or fatigue, electrolyte imbalances, nerve irritation, and certain medical conditions. Treatment for muscle spasms may involve stretching, applying heat or cold to the affected area, massaging the muscle, and taking over-the-counter pain relievers. In severe cases, prescription medications or physical therapy may be recommended to manage muscle spasms.