After the death sentence was read, Mr. Wilson, who had seemed mentally disturbed at times, stuck out his tongue at the families of the victims.

Years later, a court of appeals overturned the death sentence, but not the conviction, ruling that a prosecutor had gone too far in vilifying Mr. Wilson before the jurors. He is awaiting a ruling from the judge overseeing the case to determine whether the government can continue to seek the death penalty, or whether he will face life in prison. Lawyers for Mr. Wilson contend that his I.Q. is so low that he is not subject to capital punishment.

The affair between Ms. Gonzalez and Mr. Wilson began last March and continued until August, when he was moved to solitary confinement without explanation, according to court documents.

A special agent with the Justice Department’s Office of the Inspector General, Omar Daza, began the investigation after inmates at the Metropolitan Detention Center said they had observed Ms. Gonzalez and another inmate “hugging and kissing,” according to court papers. Another inmate reported that he saw Ms. Gonzalez in Mr. Wilson’s cell, standing in front of him while his pants were pulled down and his genitals were exposed. Some of the claims were supported by recordings from jail security cameras.

The case is being prosecuted by the office of the United States attorney for the Eastern District, Loretta E. Lynch.

The affair, which was described by Ms. Gonzalez in several recorded telephone calls, began because Ms. Gonzalez was “kind of sucked into his world.”

“I took a chance because I was so vulnerable and wanted to be loved and now I am carrying his child,” Ms. Gonzalez said in one of the calls. She was speaking to another inmate she had met inside the jail, and with whom she had continued a romantic relationship after he was transferred to another prison. (The second inmate, who was not identified, offered to raise the baby as his own when he was released.) Months later, when Ms. Gonzalez learned she was being investigated, she lamented ever having become involved with Mr. Wilson.

“I know what is going to be said about me. I know that for me as a parent, how am I going to explain this to this little boy? ‘Mommy was in the military, Mommy was a C.O.,’ ” she said, “And then the opposite end is with a person who took lives.”