Grade retention is still common practice in some countries though longstanding experience tells us that it is a highly criticised practice for its unclear benefits, its important costs for the educational systems and its relation with school dropout. Therefore, the aim of the present study is to analyse which variables increase the probability of being retained in primary education differentiating between being retained in second or in fourth grade, and paying special attention to the role of the socioeconomic status of the families. By knowing which analysed variables are related to grade retention, and how, we may offer some suggestions to reduce it. We use a national dataset with more observations for Spain than any other international ones, called ‘Evaluación General de Diagnóstico’, conducted in Spain in 2009 with the participation of 28708 students of fourth grade of primary education from 874 schools, considered to be representative for every Spanish autonomous region. This assessment focused on four competences and includes information about the learning context collected through questionnaires for students, families, school management and teachers. Estimating different multilevel random-intercept logistic regressions we obtain the following three main findings: 1) the existence of a ‘quarter of birth’ effect, that nearly doubles the probability of grade retention in second grade of primary –compared to the probability of grade retention in fourth grade–, for the youngest students of their same age cohort (OR = 1.93 vs. OR = 1.53, both p<0.001); 2) that the mothers’ education level influences more than the fathers’ one –especially in second grade (OR = 0.20 vs. OR = 0.45, both p<0.001)–; and 3) that having an unemployed father increases the probability of grade retention much more than having an unemployed mother –especially in second grade (OR = 1.48, p<0.005 vs. OR = 1.18, p>0.05)–.