The current study investigated how and when two different aspects of teacher-student relationship (TSR; closeness and conflict) influence students’ mathematical problem solving ability. Participants were 9163 eighth-grade Chinese adolescents (53.5% male) nested in 908 schools, who took part in a standard mathematics assessment and survey using student questionnaires that were all developed by the Collaborative Innovation Center of Assessment toward Basic Education Quality (CICA-BEQ) in China in 2015. The results indicated that (a) after controlling the factors of gender and SES, teacher-student closeness had a significant and positive effect on mathematical problem solving, while teacher-student conflict did not, (b) the mediating role of mathematical self-efficacy in the relationships of TSRs and mathematical problem solving was confirmed, and (c) school climate negatively moderated the indirect relationships between TSRs and mathematical problem solving.