Air conditioners and refrigerators work the same way, expect an air conditioner cools a room or a whole building.
Air conditioners use chemicals that easily convert from a gas to a liquid and back again. This chemical is used to transfer heat from the air inside of a building to the outside air.
The machine has three main parts: a compressor, a condenser and an evaporator. The compressor and condenser are usually located on the outside air portion of the air conditioner.
The evaporator is located on the inside the house, sometimes as part of a furnace. (That's the part that heats the building.)
Information courtesy of http://www.energyquest.ca.gov/how_it_works/air_conditioner.html