I used to get this quite a bit when I was in college and had a lot of bad sleep habits. I noticed it happened a lot more when I would take a nap or go to sleep super late. Definitely freaked me out a lot at first, but eventually I learned that fighting was futile and made it worse, while the best thing to do was surrender, relax, and just drift back to sleep a little more.
Nowadays I have better sleep habits and this only happens sometimes after overnight travel, but I still usually remember what's happening and can convince the lizard brain we're not dying and to chill out until we can wake up for real.