Greenhouse gases in the atmosphere trap heat trying to escape to space, thereby raising the temperature of the Earth's lower atmosphere and surface. This is the greenhouse effect.