Car: 1999 Miata, stock drivetrain. At last months autocross, about 4th run the car lost all power and wouldn't go above 3k rpm. Temp gauge on half where it should be but seemed to be hot. I did the standard run the heater and turn on the AC so the 2nd fan would turn on and after several minutes went back to normal and didn't have any issues the rest of the day. Fast forward to todays autocross. Had a co-driver today. Again 5th run did the same thing. Did what I did before and it worked, ran the heater in-between runs just in case. On the drive home worked like it's supposed to until I made a stop to pick something up. Car cooled some, drove off and after a couple blocks did the same thing. Almost had to pull off the road but took a back road with no traffic instead. After running the heater for a few minutes it went back to normal. During all this the temp gauge never went above normal but engine compartment seemed hotter than normal. Needed a rag to insulate my hand from the heat on the hood and prop. Also outside air temp last month and today was mid-90's. hot. Where do I start looking for the cause? What is the cause? Never did it before and I've been autocrossing this car for several years now. Coolant level and oil level where they are supposed to be. Ideas? Anyone seen this before?

Can you get access to a way of checking the actual temperature? Such as an infra red thermometer or a temp probe or even install an aftermarket gauge and sender.
Knowing actual temperature will tell you if your gauge is bogus.
It'll also tell you if you actually have an overheating issue or something not related.

Does your check engine light work?, have you checked for fault codes? Has the light come on whilst the fault is present?

If it is getting to hot Your ECU could be going in to limp mode if its receiving a high temp signal. Alternatively if its getting to hot, another sensor may be breaking down at higher temps.

Have you done any work to the fuel system and re routed hoses or pipes closer to something hotter? Have you got an after market exhaust, are your fuel lines shielded from it?
You could possibly have a vapour issue.

Yep. It sounds like the limp mode was due to a real over temp issue. I would start with the thermostat too. My guess is the gauge or gauge sensor are also questionable as the Guage was saying all clear. If you have gotten to limp mode multiple times I'd also flush your oil and coolant as those fluids must have been pretty worked over.