Hello,
One of the possibilities is of pelvic muscles spasms. The other possibility is of any inflammation of prostate causing prostatitis. You may need prostatic examination and prostate ultrasound and ultrasound lower abdomen to confirm. I suggest you to consult a urologist and get all these causes evaluated.
It is very difficult to precisely confirm a diagnosis without examination and investigations and the answer is based on the medical information provided. For exact diagnosis, you are requested to consult your doctor. Treatment can be started only when the diagnosis is confirmed. I sincerely hope that helps. Take care and please do keep me posted on how you are doing.
You must have some powerful spasms, or you waited too long or you may have an infection like UTI, what other symptoms do you have? How long after do you feel pain?