A brave new world is coming, and with it, wrenching change. Automation is transforming the global economy and radically changing women’s working lives for the better. That is, as long as they have the skills required to work alongside machines and move into new occupations as their jobs are replaced.

Up to 1 in 4 women could find their job disrupted by automation and may need to move into new occupations, often requiring higher skills. Worldwide, between 40 million and 160 million women may need to make these transitions, depending on the speed with which automation spreads, according to new research we released last week with the McKinsey Global Institute. Many women could also see their existing work transformed by automation technologies.

If women are able to adapt, they could be on a path to more productive, higher-paying (and potentially more satisfying) jobs. Take a nurse. Automated systems could reduce the number of hours filling in forms and other administrative tasks by around 30%, leaving them more time for interacting with patients and their families. Or consider a teacher in a more automated classroom. Automation could free up 40% of hours worked, freeing up time to coach students or develop personalized curricula.

If women aren’t able to adapt, however, the gender pay gap could widen, and women could fall further behind in the world of work. The jobs of the future will require more education and different skills. In five of six mature economies we studied, net demand for labor is expected to grow only for jobs requiring a college or advanced degree.

MGI finds that the overall impact of automation—jobs displaced and new jobs gained—could be of a similar scale for men and women, but that women will find it harder to adapt because they still face systemic barriers that have held back gender equality at work. In the automation age, women (and men) will need to be more skilled, more mobile, and more tech-savvy. Women face challenges on all three fronts.

Women are less likely to study science and tech-related subjects that will be needed to meet growing demand from employers. Due to various societal barriers, globally, women account for only 35% of STEM students. This matters if we consider that men are more present in the most lucrative professional, scientific, and technical services positions where much of the job growth will occur. A review of recently created occupations in the U.S. suggests that up to 60% of entirely new jobs such as roboticists and machine-learning specialists are in male-dominated fields. And only 8% of venture capital investors—who are increasingly focused on tech sectors—are women.

Women are also less mobile than men. They are—and feel—less safe while traveling to training or a job. The International Labour Organization finds that lack of access to and safety of transportation systems reduces the probability of women’s workforce participation by 16.5% in low-income economies. One report noted that nearly 100% of women travelers from a Paris suburb traveling to work were harassed, indicating a major problem in developed economies as well.