Girls have much lower mathematics self-efficacy than boys, a likely contributor to the under-representation of women in STEM. To help explain this gender confidence gap, we examined predictors of mathematics self-efficacy in a sample of 1,007 9th graders aged 13-18 years (54.2% girls). Participants completed a standardized math test, after which they rated three indices of mastery: an affective component (state self-esteem), a meta-cognitive component (self-enhancement), and their prior math grade. Despite having similar grades, girls reported lower mathematics self-efficacy and state self-esteem, and were less likely than boys to self-enhance in terms of performance. Multilevel multiple-group regression analyses showed that the affective mastery component explained girls' self-efficacy while cognitive self-enhancement explained boys'. Yet, a chi-square test showed that both constructs were equally relevant in the prediction of girls' and boys' self-efficacy. Measures of interpersonal sources of self-efficacy were not predictive of self-efficacy after taking the other dimensions into account. Results suggest that boys are advantaged in their development of mathematics self-efficacy beliefs, partly due to more positive feelings and more cognitive self-enhancement following test situations.