For years, Olga Khandriga dreamed of working underground at her local coal mine in eastern Ukraine. It wasn’t until Russia invaded that she got the opportunity.

As men left their jobs to fight Russia , the Ukrainian government suspended a law that had barred women from employment in “harmful or dangerous” conditions—including underground—allowing Khandriga to take over as deputy head of a section of the mine.

“I feel I’m in the right place, doing what I like to do,” said Khandriga, who studied to be a mining engineer and had worked above ground at the mine for nearly half her life.

With the war in its third year, some women are moving into traditionally male-dominated sectors of the economy to make up for a growing shortage of men. Businesses have lobbied the government to exempt more of their workers from military service, arguing that a strong economy is essential to sustaining the war effort. But with threadbare Ukrainian troops now losing ground in the east and north of the country, Kyiv has little choice. A new mobilization law came into force last week obliging all men eligible for military service between the ages of 26 and 60 to register with the authorities.

Even before the government expanded the draft, between 10% and 15% of firms’ payrolls were mobilized, according to Anna Derevyanko, head of the Kyiv-based European Business Association. “Companies are looking for females in order to hedge against this loss of labor.”

Olga Khandriga is deputy head of a section of her local coal mine in eastern Ukraine. Photographs by Svet Jacqueline for The Wall Street Journal

Beyond meeting firms’ immediate needs, economists say boosting women’s participation in the workforce will be key for Ukraine’s economic recovery after the war. Only 47.8% of Ukrainian women participated in the labor market in 2021, before Russia’s invasion, compared with 67% of American women the same year.

During World War II, millions of American women went to work outside the home for the first time, taking up jobs in factories and shipyards.

Ukraine’s case is somewhat different. While men of fighting age are banned from leaving the country, many women fled abroad as Russian forces seized territory, contributing to a significant decline in the size of the labor force. But as the economy stabilized following the initial shock of the invasion, demand for workers soon picked up.

The number of vacancies last month was higher than it was before Russia’s invasion, according to Ukraine’s biggest job ads portal Robota. Among more than 600 businesses that Robota surveyed, 75% identified personnel shortages as their biggest problem this year.

“This is the worst situation ever for employers,” said Robota’s Chief Executive Valeriy Reshetnyak.

Mass displacement to western regions away from the front line with Russia has amplified labor shortages in the east where Ukraine’s heavy industry is concentrated. Blue-collar industries that are heavily dominated by men, such as construction, agriculture and transport, are disproportionately affected by mobilization.

After Russia invaded, the head of human resources at poultry giant MHP began looking for women to fill vacancies left by men. “We realized that this was a good way to overcome the shortage of personnel,” Anastasiia Hromova said.

The company, the largest exporter and producer of chicken in Ukraine with a 26,000-strong workforce, has since trained 300 women to become locksmiths, electricians and loader drivers—traditionally jobs occupied by men.

Some roles remain unsuitable for women, said Hromova, such as loading livestock in an abattoir, which is physically demanding.

And there are still cultural barriers, compounded by the unequal share of child care and other unpaid domestic work done by women.

“Ukrainian society is quite traditional in this respect,” said Olga Kupets, assistant professor at the Kyiv School of Economics.

To overcome gender stereotypes, Kernel, Ukraine’s largest producer and exporter of grain, is preparing an advertising campaign to attract women. “We are ready to hire women to do these positions, but many don’t want them,” said head of human resources Natalia Teriakhina.

Attitudes are changing, however. When construction company owner Yulia Skichko first suggested hiring women to drive excavators and other vehicles, her male colleagues responded with derision. But the idea has gained acceptance as the war drags on, said Skichko, who recently applied for a grant from the U.S. Agency for International Development to train women to drive construction vehicles.

Swedish nonprofit Beredskapslyftet is running a program to train women to drive passenger buses.

When Iryna Meden began working as a trolley-bus driver in the port city of Odesa two decades ago, she was one of very few women in a male-dominated profession. Now, she says, more than half her colleagues are female and she no longer stands out. “A lot of men were mobilized,” said Meden.

With human resources increasingly scarce, companies are also looking to retain employees returning from the war. Reintegrating veterans is a “top priority” for Ukraine’s largest steelmaker Metinvest, its head of human resources Tetiana Petruk said. The company has already retrained some female employees to take on roles previously done by men, but it isn’t enough.

“If someone thinks women are queuing up outside our plants, this is a mistake,” Petruk said.

Ruslana Goryanska was working as a manicurist when she saw an advertisement on Facebook seeking women to work at the local coal mine run by Ukraine’s largest private energy company, DTEK. She applied without telling her husband, who also works there. He was “very surprised” when Goryanska told him she had been offered a job.

The 36-year-old leaves her 11-year-old son at home to study online while she goes to work the morning shift, clipping a head lamp to her hard hat. She passes by men emerging from the night shift, their faces grimy with coal dust, before descending over 750 feet below ground.

As an operator along a section of the mine, Goryanska is responsible for ensuring a conveyor belt of coal runs smoothly along an almost 4,000-foot stretch of the mine.

Her manager, Andriy Chornomaz, was surprised when he learned that women would be joining his shift, but he was ready to accept any help. Almost half of the men on his team went to war after Russia invaded, and the remaining 80 had to work double shifts to keep the mine operating.

“This position doesn’t involve hard physical labor, but it’s still vitally important,” Chornomaz said of Goryanska’s role.

For Goryanska, the benefits are clear: She earns twice as much as she did at the beauty salon for half the number of hours. The job also gives her a greater sense of purpose. “I feel that I am doing something really important,” she said.

Overall, there are 600 women now working at the mine—both above and below ground—compared with 500 before the war. But chief engineer Oleksandr Aksyonov said he wasn’t looking to establish new norms. “I think women still should work in safer places.”

The longer the war goes on, however, the less reversible change may be. “Unfortunately, a lot of men won’t come back at all and many will return disabled, so we should be prepared to take on more responsibility,” Goryanska said.

Several months after starting her new job, Goryanska returned to the salon where she used to work and told the hair stylist there about it. After hearing about her experience, the hair stylist quit and went to work in the mines too.

Write to Isabel Coles at isabel.coles@wsj.com