ZnO- and Mg-doped ZnO samples are prepared by spray pyrolysis on conducting glass substrates to fabricate ZnO-based dye-sensitized solar cells (DSSCs). Influences of Mg-doping content on the power conversion efficiencies of ZnO-based DSSCs are investigated. X-ray diffraction results show that all the samples exhibit a hexagonal wurtzite structure. Scanning electron microscopy data indicate that the ZnO sample has uniform rods with 1 mu m diameter. With respect to ZnO, the band gap value of 4 at.% Mg-doped ZnO samples improves to the value of 3.27 eV and a further increase in Mg level up to 6 at.% gives rise to a decline in the band gap value of 3.22 eV. Photoltuminescence measurements illustrate that intensities of the ultraviolet peak and a red luminescence peak take their maximum values for 4 at.% Mg doping. From solar cell performance measurements, the best power conversion efficiency of 0.08% is obtained for the doping amount of 4 at.% Mg.