Idle problen

I have a 2002 ford ranger with 4.0 V6. when at idle the air conditioner compressor kicks in and when it does it almost kills the engine. as soon as it kicks in the engine idle goes very low and almost dies and immediately the compressor kicks back out. it does not cool of course while idling but as long as rpm’s are up like while driving down the road the air conditioner cools very well.

Unplug the IAC (idle air control) valve and see if it makes any difference.

Yes, that sounds like a failed (or stuck closed) IAC.

The idle air control valve (iac) may be plugged with deposits. Use a Throttle Body Cleaner to spray clean it. The iac may have to be removed to clean it good.
http://www.autozone.com/autozone/repairinfo/repairguide/repairGuideContent.jsp?fromSearchPage=true&pageId=0900c152801f161c&partName=Idle+Air+Control+Valve&partId=0900c152801f161c

thank you all so much. here’s what i have done. this afternoon i replaced the battery. not cuz i thought it would help, because i had it checked the other day and it showed weak. after i did this i unplugged that valve. truck would attempt to start but wouldn’t. i plugged valve back in and now it does just fine. does that make sense?

If the electrical connector was dirty, unplugging and plugging probably scrapped off a touch on corrosion that was messing things up.