Mohamad Khweis, 27, of Alexandria, Va., was captured by Kurdish forces in Iraq in March 2016. (U.S. District Court/AP)

Fifteen months after he was captured fleeing Islamic State territory in Iraq, Mohamad ­Khweis remains an enigma.

“It’s an unusual case,” U.S. District Judge Liam O’Grady said Friday in sentencing the Virginia man to 20 years in prison for supporting the terrorist group. “There’s no event, no instigation, no suicidal ideation, no friend who radicalized you.”

Khweis, a 27-year-old former bus driver from Alexandria, Va., came from a stable and secular home, his attorneys said. He got an associate degree in criminal justice and held steady work. While he began abusing marijuana and drifting in recent years, he was never violent and left no trail of radical musings. He showed no particular interest in religion.

Yet in late 2015, he sold his belongings, flew to Turkey and contacted Islamic State recruiters to smuggle him across the Syrian border into the group’s territory. Three months later, he sneaked out and was arrested by Kurdish forces.

He insisted on going to trial, saying he merely wanted to experience the “caliphate.” This summer, a jury found him guilty of two terrorism-related counts and one weapons charge.

In a letter to the judge from the Alexandria jail, Khweis said he regretted his actions from the moment he stepped foot in Syria.

“I hated myself for making the worst decision I ever made,” Khweis wrote. “I ruined my life and my family’s life.”

He said he wanted to scream as he ran from a militant safe house in the middle of the night, his eyes filled with tears.

But he did not explain how he ended up there in the first place.

“It’s difficult to understand,” defense attorney John Zwerling said in court Friday. “We don’t really know what caused him to travel to Syria.”

Zwerling acknowledged that Khweis lied on the stand in his jury trial, the first for an American who joined the Islamic State.

Khweis claimed his decision to sneak across the border from Turkey to Syria was largely a drunken impulse, that a reference to martyrdom in his Twitter handle was accidental, that his use of multiple online accounts and anonymous browsers was to avoid hacking rather than surveillance and that he burned several phones before leaving the Islamic State because he didn’t want terrorists to learn his credit score.

Khweis “made an absolute mockery of his oath,” prosecutors Dennis Fitzpatrick and Raj Parekh wrote in their sentencing filing, showing he “learned nothing” in the 15 months between his arrest and his trial.

“He lied repeatedly,” Fitzpatrick said at Friday’s sentencing. “This defendant has a radicalized mind. He does not want to abide by the norms of society.”

Khweis had likewise lied when he was captured in Iraq in March 2016, telling FBI agents that he had been following a young woman, who did not exist. But he eventually came clean, giving what investigators described as valuable insights into the workings of the Islamic State.

At sentencing, Zwerling revealed that Khweis had identified four Western members of the Islamic State, including one American. The former recruit looked at maps and tried to point out the safe houses where he had been held and described what was done there.

His trial exposed details of the terrorist organization’s operations: Khweis was required to have his blood tested for hepatitis B and HIV. A detailed form listed his shoe size, skills and his “specialty before jihad.” He was asked whether he would be a suicide bomber. He met members of a group called Jaysh al-Khalifa that trains Islamist militants for attacks abroad.

“Because Mr. Khweis will not be the only young man to engage in this travel, it is imperative to ask — when those youth change their minds, do we want them to turn themselves in and provide valuable intelligence information, or do we want them [to] stay under ISIS control, possibly causing harm to themselves or others?” Zwerling and fellow defense attorney Jessica Carmichael wrote in a sentencing memo.

Parekh argued that the detail Khweis was able to provide was a sign of how enmeshed he was in the Islamic State and a reason to punish him harshly.

“He was a jack of all trades,” Parekh said at sentencing. “He received an inner-workings view of this organization.”

Prosecutors had asked for a sentence of 35 years, defense attorneys for five. Khweis could have gone to prison for life.

“I believe you left because you became disillusioned,” O’Grady said in selecting the punishment. “You didn’t harm anybody. You didn’t kill anybody. You left of your own volition.”

Khweis did not speak in court Friday before his sentencing. His attorneys said he was too nervous.