Individuals’ favorite subjects in school can predetermine their educational and occupational careers. If girls develop weaker preferences for science, technology, engineering, and math (STEM), it can contribute to macrolevel gender inequalities in income and status. Relying on large-scale panel data on adolescents from Sweden (218 classrooms, 4,998 students), we observe a widening gender gap in preferring STEM subjects within a year (girls, 19 to 15 percent; boys, 21 to 20 percent). By applying newly developed random-coefficient multilevel stochastic actor-oriented models on social network data (27,428 friendships), we investigate how social context contributes to those changes. We find strong evidence that students adjust their preferences to those of their friends (friend influence). Moreover, girls tend to retain their STEM preferences when other girls in their classroom also like STEM (peer exposure). We conclude that these mechanisms amplify preexisting preferences and thereby contribute to the observed dramatic widening of the STEM gender gap.