In this study, undoped and Magnesium doped TiO2 nanoparticles (Mg-TiO2 NPs) were successfully synthesized via a simple sol-gel method cost-effectively. The prepared Mg- TiO2 NPs were characterized by UV-Vis, FTIR, PL, XRD, FESEM, TEM, and EDAX. UV – Visible Spectroscopy showed that an increase in the optical bandgap concerning the concentration of dopant Mg increases. The bandgap values were found to be 3.57-3.54 eV. FTIR spectra showed that the presence of the characteristic stretching and bending vibrational band of Ti – O bonding at 468 cm-1 and shifts in vibrational bands were observed for Mg-TiO2 NPs. PL spectra of Mg- TiO2 NPs at different concentrations exhibit a strong UV emission band. X-ray diffraction confirmed the formation of the tetragonal anatase phase. The average crystallite size of prepared samples was found to be 22-19 nm. The average crystallite size of Mg- TiO2 NPs decreases with increasing the concentration of dopant Mg. The FESEM and TEM analysis confirmed that the spherical morphology for both TiO2 and Mg-TiO2 NPs. SAED pattern confirms the crystalline nature of prepared samples. EDAX spectra confirm the presence of Ti, O, and Mg and confirm that Mg2+ ions are present in the TiO2 lattices. The prepared samples were investigated against gram-positive (B. subtilis and S. aureus) and gram-negative (P. eugenia and K. Pneumonia) bacteria. The prepared samples showed potent antibacterial activity against gram-negative bacteria than the gram-positive bacteria. The prepared samples show the excellent photocatalytic degradation for Methylene blue.