What engine?

There were several recent L O N G threads on this topic, try the search button to find them. Could be a vacuum leak from the brake booster, but more likely its the idle speed set too high. Here's a recent question/answer from the Toyota Trails Truck Tech column:

Quote
QUESTION:
I have a 94 4wd p/u w/ 22re. My engine runs great, except for when it is idling and I depress the brake pedal. The engine then idles really weird, kind of a strong then weak then strong then weak, so on and so forth. It never cuts out, though, and continues to idle normally when I take my foot off of the brake. I've only noticed this after driving, like at a stoplight.

ANSWER:
Assuming there are no vacuum leaks, such as in the brake booster, it's likely because your idle speed is set too high. I can exactly duplicate this "problem" in my '85 by bumping up the idle speed to a bit over 1000 RPM and it'll act as described. Turn the idle speed back to normal, and it works fine. It's really not a problem, its supposed to work this way and if everything is set properly, and you won't have the "problem".

Why is this the case? Because the ECU has logic built in that says if you hit the brakes and the engine is turning over 1000-1100 RPM, it'll cut the fuel to the injectors in an attempt to help you stop faster. After all, no sense pumping gas into the engine when you are braking to a stop. So idle rises, fuel is cut, idle falls, fuel restored, idle rises, etc. Turn the idle back to 850-900 RPM where it's supposed to be and it'll get back to normal. Idle speed is adjusted with the large slotted screw atop the throttle body. Turn it in to lower the amount of air passing through the throttle body at idle (and thus lower the idle speed).

If you don't want to do that or it doesn't fix the problem, here's a more drastic fix:
http://www.geocities.com/toyotashawn/bizzareidle.html
Which basically involves cutting the wire that feeds the brake light signal to the ECU. Without that input, the ECU will never know you are braking, so it'll not be able to cut off the fuel injectors.