Wastewater management is paramount to safeguard human health and the environment. This study addresses the knowledge gap in urban areas by examining trends in wastewater quality, both before and after treatment. Utilizing a rigorous methodology incorporating geostatistical analysis and advanced machine learning models, the study examined 303 samples from diverse locations within the study area to appraise the efficacy of wastewater treatment techniques. The results demonstrate that the Empirical Bayesian Kriging method is highly accurate in predicting wastewater quality over the whole study area with an average accuracy greater than 95%. Machine learning algorithms, including decision trees, support vector machines, and ensemble methods, have been utilized to classify wastewater parameters into distinct categories based on their type of waste. These algorithms can produce accurate results and are widely used in various applications. This study presents a framework that combines geostatistical analysis and advanced machine learning to forecast changes in wastewater quality at unknown locations and effectively classify wastewater sources. The implications of this study extend beyond the studied urban areas, benefiting regions with similar climatic and demographic profiles. These findings can potentially drive transformative changes in wastewater management practices in the studied urban areas and other regions worldwide facing water quality challenges. This study marks a significant step forward in wastewater management, offering critical insights that can aid in formulating policies.