Generally, women have been more welcomed in offices involved with arms control and nonproliferation, which center on negotiating limits on weapons rather than developing or using them.

Even so, to be successful in these posts so critical to national security, women pay a “gender tax,” performing “the constant mental and emotional calculus that comes with implicit sexism; explicit sexism and discrimination; gender and sexual harassment; and gendered expectations,” according to the New America study, based on interviews with 23 women who held senior government positions.

Nearl y all of the 23 said they were harassed or saw others harassed, and when a foreign official was involved, the stress was magnified because it could cause an international incident.

During a round-table discussion with Global Politico in 2017, Laura Rosenberger, who spent 11 years at the State Department and the National Security Council, talked about wearing more pantsuits and baggier tops as a defense mechanism “to make myself seem less attractive in the workplace.”

Mieke Eoyang, who served 12 years as a staff member on the House Armed Services Committee and the House Intelligence Committee, has described how she would walk into a meeting and be asked to get coffee or how a committee chairman cornered her at a reception to discuss his sexual prowess.

Michèle Flournoy, a former senior Pentagon official who was expected to be the first female defense secretary if Hillary Clinton had won the presidency, told me she was fortunate enough to have supportive, often male, mentors and to have risen quickly in the field. She was, hence, less vulnerable to sexism and discrimination. But she has won plaudits as an inspiring leader who helps younger women advance.

Ms. Holgate predicts even greater strides for the next generation. There is a new vocabulary for identifying discriminating behavior — men-only expert panels are now mocked as “manels,” for instance — and more men are standing up for their female colleagues, she said.