We study the treatment effect of grade retention, using a panel of French junior highschool students, taking unobserved heterogeneity and the endogeneity of grade repetitions into account. We specify a multi-stage model of human-capital accumulation with a finite number of types representing unobserved individual characteristics. Class-size and latent student-performance indices are assumed to follow finite mixtures of normal distributions. Grade retention may increase or decrease the student’s knowledge capital in a type-dependent way. Our estimation results show that the Average Treatment effect on the Treated (ATT)of grade retention on test scores is small but positive at the end of grade 9. The ATT of grade retention is higher for the weakest students. We also show that class size is endogenous and tends to increase with unobserved student ability. The Average Treatment Effect (ATE) of grade retention is negative, again with the exception of the weakest group of students. Grade repetitions reduce the probability of access to grade 9 of all student types.