I just finished diagnosing my father in laws 91 Ranger with the 3.0 that had the exact same issue.
His problem was that the air intake tube was old, brittle and falling to pieces. When we first got the truck, the idle was high. I simply removed and cleaned the Intake Air Control (IAC) valve. You'll see it easy enough as a cyndrilical looking thing on the throttle body/ intake plenum with a 2 wire electrical plug. It is a two piece unit comprised of a solenoid that pushes on a plastic coated rod in the tube. This rod can get gummed up which will cause it to "stick" open, or some small debris can also lodge it open. This causes more air intake than desired and the engine will rev up to balance the air/fuel mix.
I ended up replacing ours recently just because it was old, not because it was broke. its a $30-80 part depending on where you buy (rockauto.com, orielly's, autozone, etc).
I've since spent the past 2 weeks trying to fix the idle/CEL problems I've had after the IAC replacement. BTW, the IAC valve replacement didn't cause these issues, it just didn't resolve them.
Well, come to find out, the engine was running timing at 40+ deg BTDC (Before Top Dead Center). On the 91, this was checked by taking a white or yellow chalk (I used a yellow map pencil) and marking the 10 deg timing line that is etched in to the factory harmonic balancer. Then, with your favorite timing light, look to see were that mark lines up in relationship to the "pointer" on the Timing cover. For me, this "pointer" was just a little sharp jut of metal that came to the rough shape of a point and happened to be pretty close to the timing marks on the balancer.
Even though the engine ran "fine-ish" and I got it to idle around 900-1K Rpms... Once I returned the timing to the 10 deg BTDC that is factory for my motor, it idled GREAT and I stopped throwing codes.
My guess is that the previous owner had a host of issues that they fixed with a piece of black tape over the check engine light and massive timing retard. They basically caused the computer to use factory tables vs sensor input. I fixed the issues by actually diagnosing and correcting the problems.