We describe an experimental setup for studying gas adsorption and chemical surface reactions by scanning tunneling microscopy (STM) at gas pressures ranging from ultrahigh vacuum (UHV) to 1 bar. The apparatus is designed for experiments to bridge the so-called pressure gap in catalysis research by obtaining atomic scale information about catalytic reaction mechanisms under steady-state conditions. It combines a UHV chamber for sample preparation and post-reaction surface analysis with a small high-pressure cell (volume 1.5 l) which contains the STM. Several concepts to improve the variable-pressure performance of existing high-pressure STM designs are described. These include access to the entire pressure range between UHV and 1 bar without triggering gas discharges, the potential for high-speed scanning and for variable temperature measurements. The design also features a fast transfer mechanism from the reactor to UHV, thus allowing for fast analysis of surface species after high-pressure experiments. First results with atomic resolution were obtained on a Ru(0001) surface at high oxygen pressures. The images show an O(1×1) adsorbate layer not observed in UHV experiments at room temperature.