Wastewater-based epidemiology has been widely used as a cost-effective method for tracking the COVID-19 pandemic at the community level. Here we describe COVIDBENS, a wastewater surveillance program running from June 2020 to March 2022 in the wastewater treatment plant of Bens in A Coruña (Spain). The main goal of this work was to provide an effective early warning tool based in wastewater epidemiology to help in decision-making at both the social and public health levels. RT-qPCR procedures and Illumina sequencing were used to weekly monitor the viral load and to detect SARS-CoV-2 mutations in wastewater, respectively. In addition, own statistical models were applied to estimate the real number of infected people and the frequency of each emerging variant circulating in the community, which considerable improved the surveillance strategy. Our analysis detected 6 viral load waves in A Coruña with concentrations between 103and 106SARS-CoV-2 RNA copies/L. Our system was able to anticipate community outbreaks during the pandemic with 8–36 days in advance with respect to clinical reports and, to detect the emergence of new SARS-CoV-2 variants in A Coruña such as Alpha (B.1.1.7), Delta (B.1.617.2), and Omicron (B.1.1.529 and BA.2) in wastewater with 42, 30, and 27 days, respectively, before the health system did. Data generated here helped local authorities and health managers to give a faster and more efficient response to the pandemic situation, and also allowed important industrial companies to adapt their production to each situation. The wastewater-based epidemiology program developed in our metropolitan area of A Coruña (Spain) during the SARS-CoV-2 pandemic served as a powerful early warning system combining statistical models with mutations and viral load monitoring in wastewater over time.Supplementary InformationThe online version contains supplementary material available at 10.1007/s11356-023-27877-3.