Women with primary dysmenorrhea have abnormal contractions of the uterus due to a chemical imbalance in the body.
For example, the chemical prostaglandin control the contractions of the uterus.
Secondary dysmenorrhea is caused by other medical conditions, most often endometriosis.
During your period, the uterus contracts to help the lining shed. This contraction compresses the blood vessels in the lining, temporarily cutting off the blood and oxygen supply to your uterus. The lack of oxygen in the tissues of your uterus causes chemicals to be released that can trigger pain.