In this work, Mg doped zinc oxide (MgxZn1−xO, x = 5, 10 and 20 at. %) nanowires were successfully prepared by two step process. Initially, ZnO nanowires were grown by thermal evaporation of Zn powder under oxygen atmosphere. Mg powder was doped in as grown ZnO through solid state diffusion at low temperature. Energy dispersive x-ray spectroscopy (EDAX), transmission electron microscopy (TEM), X-ray diffraction (XRD) and UV–Visible absorption spectra analysis reveals that the Mg doping on ZnO nanowires induces lattice strain in ZnO. Rietveld analysis of XRD data confirms the wurtzite structure and a continuous compaction of the lattice (in particular, the c-axis parameter) as x increases. The hydrogenation properties of ZnO nanowires and Mg doped ZnO (MgxZn1−xO, x = 0, 5, 10 and 20 at. %) nanowires were studied. The hydrogenated samples were further investigated through XRD and Fourier transform infrared spectroscopy (FTIR). The hydrogen storage capacity of as grown ZnO nanowires has been estimated to be 0.57 wt. % H2 at room temperature. However, the hydrogen storage capacity gets increased to ∼1 wt. % upon doping ZnO with 10 at. % Mg. Further increase in Mg concentration decreases the hydrogen storage capacity of ZnO nanowires. Thus for 20 at. % Mg doped ZnO; the hydrogen absorption capacity gets decreased from ∼1 wt. % to 0.74 wt. %. The mechanism of hydrogen storage in ZnO nanowires and Mg doped samples of ZnO has been discussed.