Very detailed answer from previous responder. Sounds like a winner but more briefly there are a couple of things that could cause it if the transmission is an A4LD which is a 3 speed automatic with overdrive. There is a torque convertor lock-up solenoid inside the pan that could be faulty and A4LDs are notorius for failing or acting up due to the servos (on passenger side of transmission about midway of transmission) being exposed to heat off of the exhaust which comes so close that they put a heat shield as a patch after the first few years of A4LDs had servos baking and failing. The 2 servos can be accessed from outside the transmission and one affects two gears and the other two gears. I vaguely remember the technician at the transmission shop say that could be an issue with mine. Turned out to be the solenoid.
I would be more inclined to believe that it is the overdrive solenoid malfunctioning. The previous writer is on the right track if you are not able to change out (after checking) the solenoid. I agree that unless you are hauling a heavy load the OD should never be disengaged which of course a driver could do by down-shifting the transmission by hand to 3rd gear. This was NOT one of Ford's "better ideas". I have changed out the solenoid on a couple Ranger A4LDs and I had to remove the filter and the valve body briefly to remove the solenoid. My solenoid was only $30 and L lost a few quarts of transmission fluid. While I had my pan off I installed a drain plug in the transmisson pan so that I could change my fluid in the future without making a major mess. I feel the other writer was probably more of an expert but I wanted to share my experiences with Ford Ranger transmissions and I repeat my experience is limited to A4LD transmissions so count the bolts on the pan to determine what transmission you have If you do not see a tag on it.
Good luck.
Kaiser Willy