Oxygen was observed to influence the electrical and optical properties of GaN layers grown by metalorganic vapor phase epitaxy. The carrier concentrations obtained from Van der Pauw-Hall measurements increased an order of magnitude when oxygen was incorporated into the grown layers. Additionally, the presence of oxygen in the GaN layers also changed the compensation behavior of Zn. Anomalous behavior of optical transitions in the oxygen-doped GaN layers was observed by optical absorption spectroscopy and low-temperature (4.2 K) photoluminescence measurements. These properties were studied as a function of growth parameters including growth temperature, amount of doping, etc. A model based on impurity band formation is proposed to explain these experimental results, and it is concluded that oxygen is a "shallow" deep donor in GaN.