She left active duty with the Air Force in 2008 but spent another two years working as a contractor. She helped manage the same highly classified program involving informants working against Iran.

A person familiar with her case said she had grown disgruntled while working for the Air Force and at some point had become enamored with Persian culture and converted to Islam. In early 2012, she traveled to Iran to attend a conference called Hollywoodism. Prosecutors said the conference is sponsored by the Islamic Revolutionary Guard Corps, an elite Iranian paramilitary force, and is intended to promote anti-American propaganda.

While at the conference, she agreed to appear in at least one video in which she was identified as a veteran and made statements that were critical of the United States. The videos were broadcast by Iranian news outlets.

After her return to the United States, the F.B.I. paid a visit to Ms. Witt, the indictment said, and delivered a warning: Iranian intelligence services were trying to recruit her. She told the F.B.I. agents she would never reveal the work she did for the Air Force.

The Iranians continued to target Ms. Witt, according to the indictment. In June 2012, an American-Iranian journalist, Marzieh Hashemi, came to the United States and hired Ms. Witt to work on an anti-American film.

In 2013, Ms. Witt traveled to Iran again for a Hollywoodism conference and met with members of the Revolutionary Guard and expressed views critical of the United States. She also stated her desire to immigrate to Iran, prosecutors said.

The indictment said she communicated frequently with Ms. Hashemi, who is identified as “Individual A.” She told Ms. Hashemi the work she had done for the Air Force was “evil.” She also talked about exposing a secret program and “do like Snowden,” a reference to Edward J. Snowden, a former National Security Agency contractor who stole sensitive documents and gave them to journalists.