Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

An American ISIS defector who allegedly told the FBI he "gave himself" to the terrorist group appeared Thursday in a U.S. courtroom to face federal charges that could put him behind bars for up to 20 years.

Mohamad Jamal Khweis, who was captured by Kurdish authorities in Iraq after he bolted from ISIS, was ordered held without bail at the hearing in his home state of Virginia.

Khweis, 26, the American-born son of Palestinian immigrants, is charged with material support of ISIS. He said nothing during the brief proceeding but waved and smiled weakly to his parents as he was led away.

His attorney, John Zwerling, hinted outside court that he may argue statements Khweis made to Kurdish officials and FBI agents were given under duress and shouldn't be used as evidence.

"The government's version of everything is not as it appears," Zwerling said.

He said Khweis' parents were relieved he was returned to the U.S. nearly three months after his capture made international headlines.

"They are glad he's home," Zwerling said.

Booking photo for Mohamad Khweis. Fairfax County Police Department

"It's a lot better than a prison in Erbil," he said of the city in the Kurdistan region of Iraq where Khweis had been held.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

A federal criminal complaint against Khweis was unsealed Thursday hours before he was brought into court wearing a blue prison shirt and a sheepish expression.

An affidavit by one of two FBI agents who interrogated him while he was in Kurdish custody said he told them he started researching ISIS — referred to as ISIL in the court papers — in December 2015.

He started by contacting ISIS-affiliated social media accounts, then sold his car and flew to London, where he sent a message to a "well-known Islamic extremist cleric who supports terrorism," the affidavit said.

Once in Turkey, he used the code-phrase "green bird" — which signals support for jihad — to make ISIS recruiters comfortable with him, authorities said. During a stint at an ISIS safe house in Raqqa, Syria, another member asked him if he wanted to be a suicide bomber.

"The defendant answered 'yes,'" the affidavit said, adding that Khweis thought the question was intended to test his commitment to the cause.

"During the interview, the defendant stated he 'gave himself' to ISIL and that they controlled him. The defendant stated he was aware that ISIL wants to attack and destroy the United States," an affidavit from an FBI agent says.

"The defendant stated that ISIL wants America to be taken over."

Investigators said when they examined Khweis' electronic devices, they found terrorist propaganda — including images of the World Trade Center burning on 9/11, and photos of ISIS leader Abu Bakr al-Baghdadi.

Before the FBI questioned to Khweis, he gave a statement that aired on Kurdish TV in which he portrayed himself as an almost accidental recruit, saying he met an Iraqi girl while traveling in Turkey and decided to follow her to Mosul.

"It was pretty hard to live in Mosul," he said. "It's not like the Western countries ... There's no smoking."

Wanting out, Khweis said, he sought out the Kurds to help him get back to the Turkish border. He was captured by Kurdish Peshmerga military forces near Sinjar on March 14 as he tried to enter the Kurdistan Region from Mosul.

He told the TV station that signing up with ISIS had been a "bad decision."

"I don't see them as good Muslims," he said. "I wanted to go back to America."

Khweis later told the FBI that "he provided misleading information in the video for self-protection," but no specifics were given, the agent's affidavit said.

A driver's license obtained by Voice of America identifies a fighter detained in Iraq as Muhammed Jalal Khweis from Virginia. via Voice of America

Zwerling pointed out that FBI agents were not on site when the Kurdish video was made and that Kurdish authorities were always in the room when the FBI spoke to Khweis later.

"He answered in the way they wanted to hear," Zwerling said.

But in the affidavit, FBI Special Agent Victoria I. Martinez emphasized that Khweis voluntarily waived his Miranda rights to a lawyer and agreed to tell FBI agents the details of his time in ISIS territory. She said that in a longer version of the Kurdish TV video, Khweis appeared "lucid, uninjured and free from duress."

"The defendant is shown in the video walking into a room on his own accord and free from any constraints," Martinez said. "The defendant is depicted in the video freely smoking cigarettes as he speaks, and smiling and laughing at times.”

Khweis' state of mind could prove critically important at trial, according to one Justice Department official, who said prosecutors may not be permitted to use his statements in court if he claims they were made under duress or after rough treatment by his Kurdish captors or even by ISIS.