We present the design and performance of an ambient-pressure atomic force microscope (AP-AFM) that allows AFM measurements using the laser deflection technique in a highly controlled environment from ultra-high vacuum (UHV) up to 1 bar with various gases. While the UHV of the AP-AFM system is obtained by a combination of turbo-molecular and ion pumps, for the higher-pressure studies, the ambient-pressure chamber is isolated from the pumps and high-purity gases are dosed via a leak valve from a gas manifold. The AP-AFM system, therefore, provides versatile AFM techniques, including the measurement of topography, friction and local conductance mapping, and force spectroscopy in a highly controlled environment with pressures ranging from UHV up to atmospheric pressure. Atomically resolved stick-slip images and force spectroscopy of highly ordered pyrolytic graphite (HOPG) at variable pressure conditions are presented to demonstrate the performance of the AP-AFM system. Force spectroscopy results of vacuum-cleaved HOPG, followed by exposure to lab air, oxygen, and methane show that adhesion between the AFM tip and the HOPG depends significantly on the exposed gas and pressure. Our results show that the deposition of airborne hydrocarbon impurities at ambient conditions leads to a significant change in adhesion force, implying that the wettability of the HOPG surface depends on the environment and the pressure. Published by AIP Publishing.