The working fluid arrives at the compressor as a cool, low pressure gas. The compressor squeezes this working fluid, packing its molecules more tightly together so that their density and pressure increase. The squeezing process also does work on the working fluid, increasing its energy and therefore its temperature. The working fluid leaves the compressor as a hot, high pressure gas and flows into the condenser. The condenser has metal fins all around it that assist the working fluid in transferring heat to the surrounding outdoor air. As this transfer takes place, the closely spaced molecules of the working fluid begin to stick to one another, releasing additional thermal energy into the surrounding air and causing the working fluid to transform into a liquid. By the time the working fluid leaves the condenser, its temperature has almost dropped back down to the outdoor temperature but it is now a liquid rather than a gas.
This high pressure liquid then flows into the evaporator through a narrow orifice. This orifice allows the liquid's pressure to drop so that it begins to evaporate into a gas. As it evaporates, it extracts heat from the air around the evaporator because that heat is needed to separate the molecules of the working fluid. Like the condenser, the evaporator has metal fins to assist it in exchanging thermal energy with the surrounding air. By the time the working fluid leaves the evaporator, it is a cool, low pressure gas. It then returns to the compressor to begin its trip all over again.
Overall, the working fluid releases heat into the outside air and absorbs heat from the inside air. The direction of heat transfer, from a cooler region to a hotter region, is the reverse of normal and requires an input of ordered energy so that it doesn't violate the second law of thermodynamics (the disorder of an isolated system can never decrease). This ordered energy is used to operate the compressor and is converted into thermal energy in the process. This additional disordered thermal energy enters the outside air and makes up for the additional order that's given to the indoor air as that air is cooled.
From "How Things Work"