More specifically, what happens is that the membranes of muscle cells become more permeable to calcium ions. Living muscle cells expend energy to transport calcium ions to the outside of the cells. The calcium ions that flow into the muscle cells promote the cross-bridge attachment between actin and myosin, two types of fibers that work together in muscle contraction. The muscle fibers ratchet shorter and shorter until they are fully contracted or as long as the neurotransmitter acetylcholine and the energy molecule adenosine triphosphate (ATP) are present. However, muscles need ATP in order to release from a contracted state (it is used to pump the calcium out of the cells so the fibers can unlatch from each other). ATP reserves are quickly exhausted from the muscle contraction and other cellular processes. This means that the actin and myosin fibers will remain linked until the muscles themselves start to decompose.
Rigor mortis can be used to help estimate time of death. The onset of rigor mortis may range from 10 minutes to several hours, depending on factors including temperature (rapid cooling of a body can inhibit rigor mortis, but it occurs upon thawing). Maximum stiffness is reached around 12-24 hours post mortem. Facial muscles are affected first, with the rigor then spreading to other parts of the body. The joints are stiff for 1-3 days, but after this time general tissue decay and leaking of lysosomal intracellular digestive enzymes will cause the muscles to relax. It is interesting to note that meat is generally considered to be more tender if it is eaten after rigor mortis has passed.