I get this, too.
Try pelvic bridges three times a day (lay on your back with your knees bent, feet in line with your buttocks, and roll your hips up until your chest and belly are flat -ha ha ha- with your thighs), about ten to twenty at a time.
Then do a butterfly stretch, sitting on your butt, bring your feet flat soles together, and bring your heels as close to your crotch as possible while sending your knees to the floor.
Also lay on your back with your butt against the wall and your feet up the wall, slowly and gently let your legs fall open into a V, until they are as far open as possible. Bring them slowly back together. Repeat.
Massage will also likely be needed to get the gunk out of the muscle and help calm it down so stretching and strengthening can be effective.