It is assumed that the relationship between intelligence (defined here as reasoning skills) and students’ academic outcomes in mathematics is moderated by different internal and external factors on the individual student and classroom level. This study analyzes the question of whether classroom composition affects gifted students differently than average-ability students. Multilevel analyses were conducted using a sample of N = 333 Austrian primary school students, consisting of n = 51 mildly and moderately gifted students (IQ > 115), and n = 233 average-ability students (IQ 85–115). Data from n = 49 below-average students (IQ < 85) were taken into account at the class level. A classroom-specific effect of reasoning skills on gifted students’ outcomes could be detected. There was significant variation in the slope of the reasoning skills predictor depending on the class students were in. Additional predictors on the class level were found to exert an influence on gifted students’ performance. No evidence was found for cross-level effects. For the average-ability student subgroup, the context level explained a lower proportion of the variance. Moreover, the class regression lines indicated stable relationships between reasoning skills and mathematics achievement across classes.