Menstrual cramps are most likely caused by an excess of prostaglandins—compounds that are released from the uterine lining as it prepares to be shed. They are a necessary part of the process, but in excess, they cause pain. For prevention, consider a magnesium supplement.