Captain Rahmani was 10 years old when the United States toppled the Taliban government in Afghanistan in 2001. As the Bush administration set out to rebuild a country scarred by war, it made promoting women’s rights a priority, a bold undertaking in a deeply conservative nation where women had been barred from schools and the work force.

During her teenage years, Captain Rahmani was inspired by America’s goal of emancipating Afghan women. When she was 18, with the support of her parents, she eagerly enlisted in her country’s air force. “It has been always my dream to do this job, be a pilot,” she said. “It made me really proud.”

The American government hailed her example as a bright spot in the difficult effort to build the Afghan Air Force, which has cost American taxpayers more than $3.7 billion. The endeavor has been marred by delays, logistical challenges and wasteful spending.

After photos of Captain Rahmani wearing tan combat boots, a khaki flight suit, a black head scarf and aviator glasses were published in the press when she earned her wings in 2013, she and her relatives in Kabul began receiving death threats. At work in Afghanistan, she said, she felt unsafe because most of her male colleagues held her in contempt. Still, she put on a brave face during the early months of her training in the United States, which began in September 2015.

“I would just want to encourage all of the females around the world, especially in my country where the females have no rights, to just believe in themselves and to have more self-confidence,” Captain Rahmani told an American military journalist in March 2015 during a visit to a Marine Corps air station.