This could be the result of a couple things. First, an engine vacuum leak can cause this to happen. However, since it started and ran good the last time, I don't think that is it. Next is a component called an idle air control valve (IAC). The IAC is located on the throttle body and it's job is to maintain the engine idle speed. It's possible it is going bad or dirt and carbon are building up causing an issue.
Here are two links you may find of interest. The first explains how to service the idle air control valve. The second explains in general how one is replaced.
Here are directions specific to your vehicle for replacement. The two attached pics correlate with these directions.
2002 Ford Truck Explorer Sport Trac 4WD V6-4.0L VIN E
Vehicle Powertrain Management Fuel Delivery and Air Induction Idle Speed/Throttle Actuator - Electronic Service and Repair Procedures
1. Remove the accelerator control snow shield.
2. Disconnect the electrical connector, and remove the bolts and the Idle Air Control (IAC) valve.
1. To install, reverse the removal procedure.
Let me know what you find or if you have other questions.
Images (Click to enlarge)
Saturday, June 27th, 2020 AT 8:15 PM