Before Muhammad Dakhlalla was taken from a Mississippi court to start serving a prison sentence for planning to join ISIS, he thanked the FBI agents who arrested him for saving his life.

Dakhlalla, 22, is the son of a well-known imam in Starkville, Mississippi.

He planned to travel to Turkey to join ISIS with his girlfriend Jaelyn Young, the daughter of a Mississippi police officer. She received a 12-year prison sentence earlier this month.

Jaelyn Young and Muhammad Dakhlalla (Warren Central High School / Starkville High School)

Dennis Harmon, the Dakhlalla family's lawyer, explains to As It Happens guest host Laura Lynch that Dakhlalla "did not understand what ISIS was about. And after some time in jail actually watching TV, which he didn't before, he discovered that he probably would've been killed if he had gotten over there."

He says that Dakhlalla's father's mosque "preached ISIS like Voldemort is treated in Harry Potter. They don't speak of it. And his family didn't speak of it. So he didn't see it."

Harmon says that it was seeing the plight of the Syrian refugees that really got to Dakhlalla. "He did not expect to see that. If ISIS were good guys, there wouldn't be millions fleeing from them."

The family was shocked when their son was arrested. But Harmon says no one in the community expected it. "None of us saw it coming. I'll go one better: the FBI never saw it coming."

As it turns out, the local FBI has had an ongoing relationship with the Dakhlallas for more than a decade.

"And like anyone else who visits, if you go to their house you're gonna sit down and eat dinner. So, Muhammad has been eating dinner with the local FBI since the time after 9/11." That's when the FBI started establishing links with mosques across the U.S. to watch for suspicious activities.

Harmon says Muhammad's father, Oda, told him "he's also grateful the FBI stopped his son. And that this is not something that he was taught at home. And that Islam, as he teaches it, is a religion of peace and not of conflict."