The influence of nondissociative adsorption of oxygen molecules on the electronic structure of ytterbium films with the thickness of 16 monolayers (6.08 nm) has been studied for the first time by using scanning tunneling spectroscopy. It is established that the adsorption of O2 molecules induces the metal-semiconductor transition in ytterbium. As a result of this transition, the quantum states have disappeared in the films, which evidences for a change of bonding type in the ytterbium crystal lattice, as well as the band gap of ~0.72 eV has opened.