I had the same symptoms about a year ago on my 2002.

I replaced the distributor cap and rotor and the problem was fixed.
_________________________
2002 Xterra XE 190K
2012 Frontier S 64K
2007 Toyota Tundra 103K