I'm guessing it's a 97-99 model. In which case it may have a bad heater in the upstream O2 sensor. If the O2 sensor is disconnected and the engine runs fine like that (though you may get a code and CEL) the sensor is most likely the cause of the problem, and should be replaced using an NTK sensor preferably, and avoiding Bosch.
If you have a look at where it says 1997 TJ Wrangler on the left you can see my vehicle profile. It will help if you fill in yours with as much detail as you can. There are many changes over the years and without relevant information it can be very difficult to give accurate answers.