For years, public discourse in science education, technology, and policy-making has focused on the "leaky pipeline" problem: the observation that fewer women than men enter science, technology, engineering, and mathematics fields and more women than men leave. Less attention has focused on experimentally testing solutions to this problem. We report an experiment investigating one solution: we created "microenvironments" (small groups) in engineering with varying proportions of women to identify which environment increases motivation and participation, and whether outcomes depend on students' academic stage. Female engineering students were randomly assigned to one of three engineering groups of varying sex composition: 75% women, 50% women, or 25% women. For first-years, group composition had a large effect: women in female-majority and sex-parity groups felt less anxious than women in female-minority groups. However, among advanced students, sex composition had no effect on anxiety. Importantly, group composition significantly affected verbal participation, regardless of women's academic seniority: women participated more in female-majority groups than sex-parity or female-minority groups. Additionally, when assigned to female-minority groups, women who harbored implicit masculine stereotypes about engineering reported less confidence and engineering career aspirations. However, in sexparity and female-majority groups, confidence and career aspirations remained high regardless of implicit stereotypes. These data suggest that creating small groups with high proportions of women in otherwise male-dominated fields is one way to keep women engaged and aspiring toward engineering careers. Although sex parity works sometimes, it is insufficient to boost women's verbal participation in group work, which often affects learning and mastery.stereotypes | STEM diversity | science education | gender | social psychology I n today's globalized world, innovation in science and technology is vital for American economic competitiveness, quality of life, and national security. For the United States to maintain global leadership and competitiveness, the nation must invest in research and innovation and grow a talented, large workforce in science, technology, engineering, and mathematics (STEM). Indeed, much of the future job growth in the United States is expected to be in STEM fields, and American businesses search globally for talent (1). This raises concerns about Americans' preparedness for these jobs because too few domestic students enter STEM fields and among those who do, attrition is high. For example, only 28% of the STEM workforce is female (2), even though women represent 50% of the American population and 58% of its college-bound population (3). Clearly, women are untapped human capital that, if leveraged, could increase the STEM workforce substantially. Accomplishing this goal involves identifying academic stages in the STEM pipeline where women are less likely to enter STEM fields and more likely to exit these fiel...