in real wastewater, and then the wet biomass (without any drying step) is converted into biodiesel through alkaline in situ transesterification assisted by ultrasound. The characterization of the incoming wastewater included chemical oxygen demand (COD), biochemical oxygen demand (BOD), and heavy metal analysis; and after cultivation, a significant reduction in pollutants was observed. Total phosphorus removal reached 93%, potassium 92%, manganese 88%, and ammonia 77%. COD and BOD also decreased by approximately 40% and 47%, respectively. The maximum experimental biodiesel yield was about 43%. This approach represents a model of the circular economy, demonstrating that petrochemical wastewater can serve both as a nutrient source and as a feedstock for biofuel production.