Well, don't do that stretch, for starters, at least for now. It's impossible to say really what's going on. I have really bad hips, and frankly, that's a stretch recommended for the hips, but it does hurt my hips as well. If it were a muscle tweak, I would think it would loosen up as you hold the stretch. But if it doesn't hurt at any other time, it's probably not something as significant as a labrum tear. I think I have that, as well as bursitis, or one or the other. The only way you could get advice on what to do about it would be to get it diagnosed, which would mean x-rays which indicate if you have the hip abnormality that usually means labrum tears, and an MRI. Bursitis won't show up on anything, the doctor diagnoses it by palpation and hopes it's the right diagnosis. Treatment depends on severity, etc. But you have no pain at any other time, if I'm reading you right, and doctors can be as big a problem when it comes to orthopedics as the injury. So if it were me, I'd just not do that stretch for a time, and if nothing else hurts, it's probably not significant. If it starts to hurt in time you'll know you have a bigger problem. Mine hurts all the time -- I don't really have to do anything -- and it actually hurts least when I'm doing something. But I pay for it later. But I'm old and have a lifetime of heavy exercise behind me. I will say this, the younger you are the more the chance you can actually get a labrum tear fixed. Much harder when you're over 40. You don't say how old you are. In sum, if you stop for a couple weeks that exercise and start again and it's fine, forget about it. If things start to hurt on a regular basis, time to see someone about it. Peace.
I think you are absolutely right. Tight hip flexors are the reason that stretch usually hurts. Don't push it, you don't want to hurt yourself. However, I'd start to try to stretch (gently) your hip flexors specifically. Here's an article that has 5 stretches to try. https://www.webmd.com/fitness-exercise/fitness-hip-flexor-stretches#1 My son is a runner and soccer player. He had a hip flexor issue. He iced it and used arnica cream on it too. But mostly, it was the stretching that cured the situation. It took about a week and a half. I'd try to do these stretches and ice it along with icy hot or arnica and if it still hurts, consider a trainer. We're lucky in that our school has an athletic trainer so my son just went there for advice and treatment. But your doctor can help you, I'm sure.
Do 20 min Yoga Hip & Back Stretch for Pain Relief. Don't skip to stretch