I have personally experienced that precise symptom, from mountain biking rides or from commuting rides.
Although I am not sure what causes it, I have observed that when it happens to me, I have ridden up steep inclines in "too high" gears while remaining seated or seated too far back on the saddle. For these reasons I have changed my pedaling technique a bit, using a lot more gearshifts.
I can also recall that my problems appeared when I changed my saddle for a narrower one, so later I found that to accommodate my sit bone, I tended to sit further back, so I could catch a wider part of the saddle. No doubt I changed my saddle's fore/aft position by half an inch towards the front.
In some rare occasions I have gotten hip pain from riding in too tight, non stretching pants, like jeans, specially carrying objects in my pockets. I suspect the problem here is the pressure the clothing excepts over the hip joint while flexing up the leg. Objects like phone, keys or tools in the pockets make this worse.
Check if any of these issues is affecting you and, if you find so, try changing one thing at a time, to see if something helps.