This study uses a mixed method sequential exploratory design to examine motivational and contextual influences on boys’ and girls’ engagement in math and science, paying particular attention to similarities and differences in the patterns by gender. First, interviews were conducted with 38 middle and high school students who varied in their level of math and science engagement about their perceptions of the motivational and contextual factors influencing their level of engagement. Both boys and girls discussed how their engagement was higher in classrooms with more student‐centered instructional practices and in classrooms with highly engaged peers. Girls were more likely to discuss teacher support and personally relevant instruction as being important to their engagement in math and science. In contrast, boys reported being more engaged in math and science when they were interested in pursuing a STEM‐related career. From these interviews, we identified factors that students described as important to their engagement and tested whether these factors were statistically significant in a socioeconomic and racially diverse sample of 3,833 middle and high school students. Specifically, we tested the associations between adolescents’ motivational beliefs (e.g., utility value, attainment value, and expectancy beliefs), social support from teachers and peers, and student‐centered and relevant instructional practices with engagement (e.g., cognitive, behavioral, emotional, and social) in math and science, paying particular attention to main effects and gender as a moderator. In the majority of the models, the motivational and contextual factors were significantly related to engagement and had comparable effects for girls and boys. We documented a few significant interactions by gender that tended to mirror the patterns found in the qualitative interviews. Implications of these findings for developing interventions to increase girls’ participation in math and science are discussed. © 2017 Wiley Periodicals, Inc. J Res Sci Teach 55: 271–298, 2018