I had this same problem in my '98 Sahara, turned out that it was my O2 sensor. I replaced it with a Bosch and had the same problem. Went around the engine replacing all kinds of junk to no success. Then I read up on here about Bosch O2's and a lot of guys are saying Jeeps hate them for some reason. I replaced it with whatever other brand the auto store had and presto, no more problem. If that doesn't work check for a short in your O2 harness.
I found this same problem with a toyota and it actually turned out to be the engine temp sensor. It doesn't mean your overheating but the computer doesn't know what the temperature of the engine is to compensate. Yes there were two temp sensors one went to the temp sensor in the dash and the other to the computer. One way to test it would be to unplug when its missing real bad or not starting and see if conditions change.
I don't know if any of this pertains to the jeep, but its wort a shot.
TJs only have one temp sensor for the coolant temp, which is at the thermostat housing. The gauge displays what the PCM tells it to. If the gauge is operating normally the sensor should be ok. If the sensor needs testing it should be compared to the chart below. Could still be an overheating coil as I suggested earlier. Primary and secondary resistances should be 0.95-1.15 ohms and 11,300-15,300 ohms.
Both coolant temp and IAT sensors are used in conjunction with the MAP, CKP, CMP, O2 sensors for controlling the fuel mix and sync. Both temperature sensors will have an effect on the fuel injector pulse width. When resistive sensors fail they usually go open circuit and in the case of the coolant and IAT sensors they make the computer think the temp is -40 and this results in a rich fuel mix which can cause rough running but also causes a drop in MPG. Both sensors can be checked against the chart posted above.
The reason I suggested the coil earlier is that there's a thread in the XJ section where the guy swapped all sorts of stuff and the problem turned out to be a bad coil, which turned out to be cracked in his case. The trouble with heat soaking problems is the number of things that can be affected. It could even be a bad splice or connection that increases resistance as it gets hot.
It might be worth the OP checking the condition of his plugs since a sticking valve has also been suggested.
Replaced the plugs, plug wires, cap, rotor, ignition coil, o2 sensors, crank sensor, IAC (found out pintle was broken when i was cleaning out the throttle body), cleaning all connections and battery terminals, and running seafoam through the engine and fuel system and she still couldn't hack it at highway speeds for more than 5-10 minutes. Fine during city driving.
Replaced the fuel pump assembly and I'm back in business, 300 miles and a weekend trip to Rausch Creek with no issues. I'm thinking the pump was on it's way out and could handle low demand while city driving but couldn't take the continuous high demand while highway driving. Guess and check isn't the most cost effective way to diagnose an issue but I did notice a pretty nice increase in MPG. I guess she was just being a typical woman, you know something is wrong but she won't tell you what (no CEL) so you just keep buying things for her until she's happy again. It's too bad I couldn't just put some roses in the tank but what can you do eh. Thanks for all the help & input