Surrounded by armed Kurdish soldiers in an Iraqi field near the Islamic State territory he had fled, Mohamad Khweis asked for a cigarette.

The peshmerga all reached for their packs. Wait, the commander said, one soldier testified in federal court earlier this month. In English, he asked the American-born Khweis, “Is it nicer here or in ISIS?”

“Here,” Khweis replied, according to the soldier. “It’s more free over here.”

It was March 2016, and Khweis soon landed in a prison in Irbil, Iraq, where he was given all the cigarettes he wanted — and freely confessed, authorities say, to having joined the Islamic State. Judge Liam O’Grady agreed that those statements were voluntary and ruled Wednesday that they can be used against the Northern Virginia man when he goes to trial in Alexandria federal court next month on terrorism charges. Prosecutors and defense attorneys declined to comment on the ruling.

Mohamad Khweis after a 2010 DWI arrest. (Fairfax County Police Department)

The son of a limousine driver and cosmetologist who immigrated from Palestine, Khweis graduated from Edison High School in Alexandria in 2007 and earned an associate degree in administration of justice from Northern Virginia Community College. Before his travel and arrest, he was working as a Metro Access bus driver, according to court documents.

Khweis’s lawyers have said he was coerced into talking to FBI agents by an intense desire to go home and was blocked from seeing his attorney during the three months he was held in Iraq.

“It was apparent to every single person who interviewed him that Mr. Khweis was anxious, if not desperate, to get away from Kurdish custody and return home,” defense attorney John Zwerling said in a recent court hearing. When one FBI agent left Iraq, he wrote to co-workers that he had to “peel [Khweis] off my leg.”

The FBI kept Khweis in a Kurdish prison longer than it needed to in order to get him to talk, the defense claims, and kept him from counsel.

Prosecutors countered that Khweis was held by the Kurds in accordance with their laws. They said he was simply eager to talk about his exploits, which took him from his home in Alexandria to Syria in just two weeks.

“This defendant could not help himself,” Justice Department attorney Raj Parekh said at the court hearing. “He wants his story to be out there, he wants his time with ISIS to be known.”

FBI agent Michael Connelly, the first American to interview Khweis in Iraq, testified at one court hearing that although Khweis was cooperative, over weeks of interviews the prisoner admitted several times that he hadn’t been fully truthful and started his story again.

(Jason Aldag,Adam Taylor/Twitter/@kurdistan83)

One major lie was what Khweis told a Kurdish television station after his capture, Connelly said: that an Iraqi woman helped the American cross into Islamic State territory. Khweis actually found his way to the Islamic State alone, according to Connelly, connecting with facilitators on social media.

Defense attorney Jessica Carmichael also said that Connelly, who was conducting intelligence interviews that could not be used to bring charges against Khweis, tainted subsequent interviews in which Khweis was told he could remain silent or speak to an attorney. In emails, Connelly said he “really tee’d him up” for the FBI agents who would conduct “clean” interviews for use in court. “He is lined up perfectly for the clean team,” Connelly wrote.

Connelly testified that he was merely offering his perspective and that he had done nothing to undermine Khweis’s right to remain silent in future interviews.

Connelly said Khweis at one point voluntarily waived his right to speak to an attorney, saying it was a sign of his desire to cooperate.

“He knew this was something he couldn’t walk away from,” Connelly said.

Attorneys for Khweis suggested that their client’s cooperativeness stemmed from mistreatment in Kurdish custody. Kurdish and FBI officials disagreed, saying the American was given better treatment than other prisoners. They did acknowledge that he did not have a toilet in his cell and had complained regularly of stomach problems.

The Kurdish soldier who captured Khweis recalled that his unit came upon Khweis in a field about 4 a.m. on the morning of March 14, 2016. They fired over the stranger’s head in the dark, and Khweis hid in the tall spring grass. After about two hours, as the sun began to rise, the soldier approached Khweis alone “so if he blew himself up, we would only lose one person.”

He asked Khweis in Arabic to take off his clothes, miming the action when he didn’t comply. After searching Khweis, they let him dress, handcuffed him and drove him to a compound in Irbil.

The soldier admitted that he hit Khweis when the prisoner accused him, in Arabic, of not returning all of his money.

“I lost my temper and I slapped him, then apologized,” the soldier testified. “I felt bad and regretted it immediately.” He said he was upset by the accusation and because Khweis had not revealed his understanding of Arabic during the tense standoff that morning.

Both Kurdish officials testified through translators and were left unnamed because of concerns about their safety in Iraq.

After he got on a plane to the United States in June, FBI agent Victoria Martinez testified, Khweis told her the peshmerga had blindfolded him and threatened to execute him. At that point, for the first time, Khweis invoked his right to remain silent.

His defense attorneys say that that showed Khweis had been fearful of the Kurdish authorities and cooperating under duress.

But Martinez said Khweis soon came over and began talking to her again — a sign, prosecutors argued, that his volubility was unforced.

Emails showed that Connelly thought Khweis could be an asset to the U.S. government as a rare American defector from the Islamic State. Connelly recalled Khweis saying he “bangs on his cell door every night and asks to speak to the Americans because he remembers new ISIS information that could help the United States.”

In an email, Connelly expressed regret that he could not spend more time with Khweis, having determined that the prisoner had no more immediate intelligence to offer.

“Every [redacted] supervisor and agent in the United States working [redacted] should get a chance to talk to him,” he wrote to a superior after the interviews.

“To this day, I think he could be valuable,” Connelly testified.