Thin films of Zn1−xMgxO have been deposited using the chemical spray pyrolysis method. The variations in the chemical and physical properties of Zn1−xMgxO layers deposited with Mg-compositions in the range, 0≤x≤0.3, were investigated with respect to the deposition conditions. The Zn0.76Mg0.24O layers were used as buffer layers in thin film solar cells with the configuration, glass/Mo/CuIn0.8Ga0.2Se2/Zn0.76Mg0.24O/ZnO:Ga/Cu–Au using sprayed p-CuIn0.8Ga0.2Se2 (CIGS) as an absorber layer and sprayed n-ZnO:Ga as a window layer. The devices were characterized using current–voltage, capacitance–voltage and spectral response measurements. The best devices had a solar conversion efficiency of 3.9% with quantum efficiencies >70%. This is the first time such a device has been made in which all the layers were produced using spray pyrolysis.