In terms of molecular motion, this pressure gradient is explained by the fact that molecules existing in any horizontal slice of the atmosphere, and moving upwards, lose kinetic energy because gravity does negative work on them, just as it does on a ball thrown into the air; and molecules travelling downwards similarly gain kinetic energy.