This paper presents the results of a study of the effects of oxygen and nitrogen incorporation in Al x Ga 1-x As epitaxial layers during MBE growth. Low level controlled air leaks were introduced during growth and the structural properties of the layers measured by HRXRD, while SIMS was used to measure the oxygen and nitrogen content in the layers. The Al x Ga 1-x As lattice parameter exhibits contraction for Al fractions x up to 0.6 while layers with x fractions greater than 0.6 show an expansion in the Al x Ga 1-x As lattice parameter. The observations are interpreted by comparing these lattice parameter measurements with Al x Ga 1-x As layers grown without admitting air to the growth chamber. The x-fraction incorporation dependence, as well as the lattice parameter behavior, is accounted for by a model which discriminates between the propensities for O 2 to incorporate at As sites by bonding to pairs of Ga atoms in the layer beneath, to one Al and one Ga in the layer beneath or to two Al atoms in the layer beneath. There is also evidence that the O 2 and N 2 molecules compete for these bonding sites.