First is a build up of lactic acid from anaerobic muscle use can cause some cramping. It is produced by the rxn: CH3COCOO- + H+ +NADH --> CH3CHOHCOO- + NAD+. This is done to get rid of pyruvate from the cell (lactic acid is easier to transport out of the cell) so that glycolysis can continue (le chatelier's principle). Also a presence of lactic acid is known to cause muscle soreness.
Also some cramping is reported to be caused by the lack of minerals such as Mg and Ca, but primarily Ca. Im really not an expert on this one but as per my understanding the cramping would be caused by lack of Ca release from the skeletal muscle sarcoplasmic recticulum cisternae. Normally Ca release at the cisternae causes Ca++ to bind to troponin C which causes a conformational change in the tropomyosin which causes lateral displacement of the tropomyosin fibre which makes the myosin head binding site available. Myosin has a high affinity for actin so the myosin head binds to the actin and ATP is then hydrolyzed which causes muscle contraction. In order to stop the contraction ATP must be hydrolysized again to severe the connection but the Ca must also be taken up by the Ca/Mg ATPase pump in the sarcoplasmic recticulum which requires another ATP.
...Therefore what Im thinking is anaerobic conditions are causing a lack of ATP which both inhibits the myosin head's ability to release the actin and inhibits the ability of the Ca/Mg ATPase pump to take up the Ca and end contraction thereby causing muscle cramps.