When muscles contract, the length of the sarcomere (distance between the Z-lines*) shortens. ATP is required for the process of cross-bridge cycling which enables the sarcomere to shorten. The steps of cross-bridge cycling are as follows:
When ADP** is bound to myosin heads, they are able to bind to actin filaments of the adjacent myofibril to form a cross-bridge. Once they are attached, the myosin filaments change their angle, pulling back the actin filaments in a power stroke, releasing the ADP molecule in the process. This causes the sarcomere to shorten. Now, an ATP molecule binds to the myosin head, causing it to detach from the actin filament. The enzyme ATPase catalyses the breakdown of ATP to ADP and inorganic phosphate, which releases energy for the myosin head to return to its original position in a recovery stroke. Recall that myosin can only bind to actin when it has ADP attached, so myosin is now poised to bind once again to another actin molecule to contract the muscle further, and our cycle continues. Crucially, we need ATP to enable the actin-myosin cross-bridge to detach, and release energy through its hydrolysis to enable the myosin head to return to its resting position. Without this vital role of ATP, the cross-bridges will stay permanently bound, and the muscle will not be able to contract further, relax or initiate a new contraction. This is why, after death, when ATP is no longer being produced through respiration, muscles are permanently contracted, a condition known as rigor mortis.
ATP is also required to enable skeletal muscle to prevent further contractions when a muscle is no longer stimulated. If you recall, when a skeletal muscle is stimulated to contract, we need calcium to bind to the globular protein troponin, which causes the threadlike protein tropomyosin (which wraps itself around the actin filament) to pull away, leaving actin free to bind to myosin. To stop a muscle continually contracting after its stimulation has ended, calcium is taken up again by the sarcoplasmic reticulum*** by active transport through calcium ATPase. This requires energy from the hydrolysis of ATP.
*Z-line marks the end of the sarcomere and is the attachment point for actin filaments at each end of the sarcomere.
**ADP is one of the products of ATP hydrolysis by the following reaction: ATP à ADP + Pi (+ energy released).
***the specialised endoplasmic reticulum of muscle.