Why is it that an Aneriod Barometer Can be used to measure elevation as well as air pressure?

Is is possible air pressure changes with altitude? I know in Space the pressure is very much reduced.