Pain-Spasm-Pain Cycle
A simplified description of this cycle is easy to understand. When muscles are in flexion they can eventually become ischemic (lack of blood). Ischemic muscles cause pain.
When there is pain the muscle reacts by going into spasm thinking it is protecting itself. This causes more ischemia, pain from the ischemia, and then more spasm. In order to break this cycle the muscle needs to be released and reset.