In the past ten years we have witnessed a revival of, and subsequent rapid expansion in, the research on zinc oxide (ZnO) as a semiconductor. Being initially considered as a substrate for GaN and related alloys, the availability of high-quality large bulk single crystals, the strong luminescence demonstrated in optically pumped lasers and the prospects of gaining control over its electrical conductivity have led a large number of groups to turn their research for electronic and photonic devices to ZnO in its own right. The high electron mobility, high thermal conductivity, wide and direct band gap and large exciton binding energy make ZnO suitable for a wide range of devices, including transparent thin-film transistors, photodetectors, light-emitting diodes and laser diodes that operate in the blue and ultraviolet region of the spectrum. In spite of the recent rapid developments, controlling the electrical conductivity of ZnO has remained a major challenge. While a number of research groups have reported achieving p-type ZnO, there are still problems concerning the reproducibility of the results and the stability of the p-type conductivity. Even the cause of the commonly observed unintentional n-type conductivity in as-grown ZnO is still under debate. One approach to address these issues consists of growing high-quality single crystalline bulk and thin films in which the concentrations of impurities and intrinsic defects are controlled. In this review we discuss the status of ZnO as a semiconductor. We first discuss the growth of bulk and epitaxial films, growth conditions and their influence on the incorporation of native defects and impurities. We then present the theory of doping and native defects in ZnO based on density-functional calculations, discussing the stability and electronic structure of native point defects and impurities and their influence on the electrical conductivity and optical properties of ZnO. We pay special attention to the possible causes of the unintentional n-type conductivity, emphasize the role of impurities, critically review the current status of p-type doping and address possible routes to controlling the electrical conductivity in ZnO. Finally, we discuss band-gap engineering using MgZnO and CdZnO alloys.