Loneliness is a public health concern that increases the risk for several health, behavioral and academic problems among adolescents. Some studies have suggested that adolescents with an ethnic minority background have a higher risk for loneliness than adolescents from the majority population. The increasing numbers of migrant youth around the world mean growing numbers of heterogeneous school environments in many countries. Even though adolescents spend a substantial amount of time at school, there is currently very little non-U.S. research that has examined the importance of the ethnic composition of school classes for loneliness in adolescence. The present research aimed to address this gap by exploring the association between loneliness and three dimensions of the ethnic composition in the school class: (1) membership of ethnic majority in the school class, (2) the size of own ethnic group in the school class, and (3) the ethnic diversity of the school class. We used data from the Danish 2014 Health Behaviour in School-aged Children survey: a nationally representative sample of 4383 (51.2 % girls) 11–15-year-olds. Multilevel logistic regression analyses revealed that adolescents who did not belong to the ethnic majority in the school class had increased odds for loneliness compared to adolescents that belonged to the ethnic majority. Furthermore, having more same-ethnic classmates lowered the odds for loneliness. We did not find any statistically significant association between the ethnic diversity of the school classes and loneliness. The study adds novel and important findings to how ethnicity in a school class context, as opposed to ethnicity per se, influences adolescents’ loneliness.