Zn1-xMgxO nanocomposites were synthesized by a modified sol-gel method. The effect of increasing Mg content on structural, optical properties, and antibacterial activity was studied. The structure and physical properties of the Zn1-xMgxO nanocomposites were characterized by thermogravimetric (TG) analysis, Fourier-transform infrared spectroscopy (FT-IR), X-Ray Diffraction (XRD), and transmission electron microscope (TEM). The optical properties were investigated by UV-visible spectroscopy and Photo luminesce spectra (PL). The thermal properties and the weight stability were studied for the samples using TG-Analysis to determine the best annealing temperature at 550 °C. The XRD result confirms that clear indications for segregation into a hexagonal and a cubic phase are found for samples having magnesium content between 0.2 ≤ x ≤ 0.8. According to Scherer's formula, the average particle size of the synthesized nanocomposites is in the range of 16.32-25.56 nm. TEM images showed hexagonal, irregular, and spherical shapes. The calculated band gap energies (Eg) of the Zn1-xMgxO nanocomposites were changed from 3.18 to 3.31 eV by increasing Mg concentration in the Zn1-xMgxO nanocomposites. The XRD and UV-vis analysis results indicated that the physical characteristics of Zn1-xMgxO nanocomposites were dependent on increasing the incorporation of Mg2+ ion concentration. The antibacterial assessment illustrated that the ZnO-MgO nanocomposites showed excellent antibacterial activity, the inhibition zoon increases from 12 mm for pure ZnO to 15 mm for Zn1-xMgxO nanocomposites with Mg ratio (x=0.4). The result concluded that Zn1-xMgxO nanocomposites have significant potential for antibacterial applications.