Diversity in the geosciences is low despite efforts to improve the representation of different groups in society, for example in terms of gender. Specifically, women are underrepresented in recruitment and retention at every stage of the academic to professional pipeline. Mentoring programs can improve womens motivation and persistence in science, technology, engineering and mathematics (STEM) career pathways. However, mentorship programs consist of multiple components that vary in complexity and cost, which can limit scalability. Here we present results from a randomized experiment with 158 undergraduate women majoring in a geoscience field to identify the critical elements of a successful mentorship program. The combination of three factors was necessary to increase mentoring, motivation, and persistence: inspiration through exposure to geoscience careers via female role models, inoculation through training on how to grow their mentor network and overcome obstacles, and an introduction to a local female geoscientist mentor.