This diagram of a temperature inversion illustrates the way in which a layer of warm air traps a layer of cool air, and with it pollution, close to the ground. Without this inversion layer pollution would be able to rise into the atmosphere and disperse.
During a temperature inversion the cold layer closest to the ground is caused by cold dense air sinking down surrounding hills underneath the less dense warm air.