Paige, the pain is thought to come from the contents of the muscle cells that spill out when the cells rupture. Apparently they can be irritating to surrounding tissue.
Magnesium can help, especially if you have higher lactic acid levels which occurs with strenuous exercise (which we do without thinking every day!. You might want to try a little Milk of Magnesia...not enough to cause a laxative effect, but enough to help with acidity.