ZnO:Mg nanocomposite formation by two-step laser ablation in deionized water is analyzed. Fourier transform infrared spectroscopy (FTIR), X-ray diffraction (XRD), UV–Vis spectroscopy, scanning electron microscopy (SEM) and energy dispersive X-ray (EDX) analysis were employed to obtain infrared spectra, crystalline structures, optical absorption spectra, morphology and spatial composition of the prepared nanocomposite. The FTIR result shows that bonds at [Formula: see text]480[Formula: see text]cm[Formula: see text] and 900[Formula: see text]cm[Formula: see text] correspond to Zn–O and Mg–O stretching modes. The XRD pattern observed the hexagonal wurtzite of ZnMgO phase at [Formula: see text] and 34.76[Formula: see text]. SEM image shows a flower-like hierarchical structure with a full array about 2[Formula: see text][Formula: see text]m. The absorption spectra demonstrate that a band gap of nanocomposite increases as the Mg content increases.