We present a study on the green synthesis of undoped and Er-doped ZnO compounds using Mangifera indica gum (MI). A set of tests were conducted to assess the structure of the material. The tests included X-ray diffraction, Raman, and Fourier-transform infrared spectroscopy. Optical properties were studied using diffuse reflectance and photoluminescence. Morphological and textural investigations were done using SEM images and N2 adsorption/desorption. Furthermore, photocatalytic tests were performed with methylene blue (MB), yellow eosin (EY), and the pharmaceutical drug ibuprofen (IBU) under UV irradiation. The study demonstrated that replacing the stabilizing agent with Mangifera indica gum is an effective method for obtaining ZnO nanoparticles. Additionally, the energy gap of the nanoparticles exhibits a slight reduction in value. Photoluminescence studies showed the presence of zinc vacancies and other defects in both samples. In the photocatalytic test, the sample containing Er3+ exhibited a degradation of 99.7% for methylene blue, 81.2% for yellow eosin, and 52.3% for ibuprofen over 120 min. In the presence of methyl alcohol, the degradation of MB and EY dyes is 16.7% and 55.7%, respectively. This suggests that hydroxyl radicals are responsible for the direct degradation of both dyes. In addition, after the second reuse, the degradation rate for MB was 94.08%, and for EY, it was 82.35%. For the third reuse, the degradation rate for MB was 97.15%, and for EY, it was 17%. These results indicate the significant potential of the new semiconductor in environmental remediation applications from an ecological synthesis.