This study investigates the relationships between students’ self-concept, self-efficacy, and achievement in mathematics, considering contextual factors such as socioeconomic status, gender, and immigration background, by using Swedish data from PISA 2003 and 2012. Additionally, these relationships between the two types of schools in Sweden are compared. In Sweden, the school system generally includes municipally-run schools (public) and independent schools (also funded by the state but run privately). Findings indicate a positive correlation between robust mathematics self-concept and self-efficacy and enhanced mathematics performance. Notably, students with better socioeconomic status exhibit heightened levels of mathematical self-concept and self-efficacy, corresponding to superior mathematics outcomes. Gender nuances reveal that, despite superior mathematical performance, girls report less positive self-concept and self-efficacy in mathematics than boys. Surprisingly, mathematics self-concept tends to have a closer association with achievement in independent schools than in public schools, while mathematics self-efficacy influences achievement more in public schools than in independent schools. Besides, independent school students’ mathematics achievement is more associated with socioeconomic status and gender compared to their public-school peers. Immigration background seems to play a more important role in predicting mathematics achievement in public schools than in independent schools.