The check engine light comes on and the motor bogs down. Why is this? on 1993 Toyota Pickup

Rookie cbe0621eac06868b3efe0d8d1d3611e23c60d3114864ea2ec19a68cfbd3eebab
The motor is a 22R. If you turn the truck off while the engine light is on the starter will not work, only a click. If you turn the truck off when the engine light is off the truck will start just fine. I had the starter checked, replaced both ground wires, positive wire to starter, starter relay, and cable ends. When the light is off the truck has good power. I can drive a few miles just fine, then the light comes on and I lose power. A few blocks later the engine light goes off and the engine is normal again for 5 or 10 miles. Also replaced fuel filter.
(1) Answer
Qualified Local Toyota Shops
Qualified Toyota Shops For This Repair