We investigate the influence of the classroom environment on educational performance and its dependency on parental socio-economic status (SES). The classroom environment can have a compensatory effect and decrease educational inequality, in which case the classroom context is more important for children originating from lower SES families. Alternatively, there can be an amplifying effect, in which case the classroom environment is more important for high-SES children. This would increase educational inequality. We investigate the two alternatives by applying a twin design to data from 4,216 twin pairs from the Netherlands Twin Register (birth cohorts 1991–2002). Some twin pairs share a classroom and other twins from the same pair are in different classrooms. We use this fact to decompose the variance in educational performance at the end of primary school into four components: genetic variance, classroom variance, shared environmental variance, and non-shared environmental variance. We find that of the total variance in educational performance, only a small part (2 per cent) can be attributed to differences between classrooms within schools. The influence of the classroom was larger when the level of parental SES was lower (up to 7.7 per cent) indicating a compensatory effect.