An American citizen has been sentenced to 20 years in prison after being found guilty of joining and providing material support to ISIS terrorist group.

The man had stated that he “wasn’t thinking straight,” and left the terrorist group shortly after joining.

Mohamad Khweis, 28, of Alexandria, Virginia, was sentenced to 20 years in prison on Friday in the Eastern District of Virginia by U.S. District Judge Liam O'Grady.

Khweis was captured in Iraq in March 2016 by Kurdish Peshmerga forces, and was then handed over to the United States.

He is the first American citizen to be captured on the battlefield, the Department of Justice said in a statement.

Khweis left the U.S. in 2015 for Turkey to join ISIS. He strategically planned his travel routes in order to conceal his final destination.

“I didn't agree with their ideology,” he said, according to Fox News.

Khweis’ defense attorney John Zwerling said during the trial that Khweis is not as violent as he looks on paper.

“While he was there, he did not fight. He did not do harm to another human being,” he said. “He provided valuable, actionable intelligence, and the government has given him zero credit for any of it.”

According to evidence provided against Khweis, he spent two and a half months as an ISIS member.