Involuntary contraction of a muscle. Muscle cramping can happen at any time, generally as the result of dehydration, fatigue, or lack of stretching. To get rid of cramping, stretching and massaging is recommended. Prevention of muscle cramps includes eating potassium rich diets, staying hydrated, and stretching.