ObjectiveThis study aimed to assess socioeconomic inequalities in schools regarding the COVID-19 incidence during different epidemic waves among Barcelona students, differentiating by sex and educational stage. Study designCross-sectional ecological study. MethodsWe included in the study all students from childhood to secondary education in Barcelona city. The unit of analysis was the schools. The study covered the epidemic waves coinciding with the 2020-21 and 2021-22 school courses. The cumulative incidence (CI) per school and wave was calculated. Bivariate and multivariate analyses using Poisson regression were conducted to estimate relative risks. The population attributable risk, by sex and educational stage, was calculated as a measure of impact. ResultsIn the second wave, higher CI in students was associated with greater school socioeconomic deprivation in all groups. In the younger girls, 24.5 % (5.2–41.4) of the CI was attributed to school socioeconomic vulnerability, increasing to 33.1 % (15.1–47.2) in older girls. During the sixth wave, the impact was lower in the most vulnerable schools in all strata. ConclusionsSocioeconomic factors significantly impacted the incidence of COVID-19 in schools, reflecting social inequalities in Barcelona. There was an inversion of the pattern of inequalities in the sixth wave compared to the previous ones. The results emphasize the need for urgent action and targeted resources to address health inequalities in education and understand the impact of epidemic dynamics on socioeconomic context.