Thin films of magnesium doped zinc oxide (MZO) were synthesized using the sol–gel method and annealed at different temperatures under ambient condition. The morphological properties of the post annealed MZO films were investigated using X-ray diffraction (XRD) while atomic force microscopy (AFM) was employed to probe the topographical alteration of the films. The optical properties of the post annealed MZO films were examined by UV-visible spectroscopy and the Tauc method was used to estimate the optical band gap. The studies revealed that, with the rise of annealing temperature the crystallinity and the surface roughness of the MZO films were increased whereas the optical transmittance and the energy bandgap were decreased.