Air conditioners and refrigerators work the same way. Instead of cooling just the small, insulated space inside of a refrigerator, an air conditioner cools a room or a whole house. Air conditioners use a working fluid, or refrigerants, that can be converted from a gas to a liquid and back again. As long as liquid and gas are present (within the envelope in the lower figure) one pressure will have a corresponding temperature, which is a property for the used refrigerant.
The refrigerant transfer heat from the air inside of a room to the outside air. The AC unit has four main parts; a compressor, a condenser, a pressure reducing valve and an evaporator. The compressor and condenser are located on the outside of the room. The evaporator, that cools you room(s), is located on the inside.
The refrigerant arrives at the compressor as low-pressure gas (2) with corresponding low temperature. Driven by an electrical motor the compressor gives the refrigerant gas a high pressure (3) with a corresponding high temperature. This gas flows into the condenser outside the house. In the condenser the gas condenses to liquid (3-4) which release energy (read enthalpy in the diagram) to the surroundings. In order to do so the refrigerants condensing temperature must be above the outside air temperature.
When the refrigerant leaves the condenser it has changed from a gas to a liquid(3-4). The liquid goes through a pressure reducing valve into the evaporator (4-1). The liquid’s pressure drops as well as the temperature. The refrigerant begins to evaporate into a gas which require energy (enthalpy) which is taken from the air inside the room and cools it (1-2). Thus the refrigerant must have a temperature that is below the wanted temperature within the room.
By the time the refrigerant leaves the evaporator, it is a cool, low pressure gas (2). It then returns to the compressor to begin its trip all over again. This continues over and over and over until the room reaches the temperature you want the room cooled to.