Muscles can spasm for any number of reasons. A spasm may be a twitch in the muscle or may feel tight or hard, like a knot. After the contraction stops, the muscle can feel sore and tender. Sometimes severe spasms can be incapacitating.

A 2016 review article on spasms reported an observational study with three participants who used hyperventilating (yes, just breathing) at 20 to 30 breaths per minute to resolve exercise-related cramps.
Hyperventilation is when you breathe harder and faster than normal. If you have anxiety, hyperventilation may not be a good choice for you, as it can induce feelings of panic.

Courtesy: healthline