Antlery, I had/ have the same problem with my 02 KJ. The electronic lock cylinder actuator has gone/ is going bad. Basically for me one day I had full function of the tail gate and none the next, did some investigation and this is what I found.
IF your tail gate won't open get a flash light and a flat tip screwdriver, flip your rear seats down, pry open the access panel on the tail gate (lower left from inside when tail gate is shut) with the screwdriver, peel back the protective film and insulation. If you lay down in the jeep facing the rear, look into the access panel at the slight upper left and you'll see a small black nubbed end, this the end of the actuator that drives the keyed and key less operation. Reach in and flip/ toggle the switch up you'll physically hear it "click" your tailgate will now open.
While your in there you could try adding a lubricant to the moving parts or spray some electrical cleaner on them.
By doing the above it most likely won't permanently fix the problem as I've been doing the above stated for 2 plus years now. Occasionally I have to reach in through the back window and manually actuate/ flip the switch as a result I just leave that small inspection plate/ access panel off. Sometimes the lock mechanism works flawlessly for 4-6 months straight other times I might only get a week before repeating the process. I've had a hard time justifying spending the $250+ for the new switch.
Anyways, hope this helps you.