It’s most likely either a bad coil pack on the 4.0l 6 or the Cam position sensor. The Cam sensor is more common, but when I had that problem it stopped and never started again. When I had the coil pack problem it behaved like you are describing. I have a 2001 Cherokee with the 4.0l 6, same engine as the Wrangler.
I need to correct myself I meant to say crank sensor not Cam sensor.