A Somali man who's been in custody for more than two years while he faces terrorism-related charges will be released to his family's home in Minnesota under strict conditions while he awaits sentencing, a federal judge ruled Wednesday.

Kamal Said Hassan, 26, was one of about 20 young men who authorities believe left Minnesota to join the terror group Al-Shabab in Somalia. Hassan pleaded guilty in 2009 to three counts, including providing material support to a terrorist group.

He's been in custody at the Sherburne County jail ever since. Over prosecutors' objections, Chief U.S. District Judge Michael Davis said Wednesday that Hassan will be released to the family home on Sept. 28 -- but will be on 24-hour lockdown, with GPS monitoring and other restrictions. He will be allowed to leave only for court-approved medical appointments and court appearances.

"If there is a violation of you being outside the home, smelling the flowers or looking at the birds, understand you will be taken into custody," Davis said.

According to court documents, Hassan attended an Al-Shabab training camp in Somalia and continued to follow orders from the terror group after he left the camp.

Al-Shabab was declared a terrorist group in early 2008.

Over the past three years, Minnesota has been the center of a federal investigation into travels and recruiting of people from the U.S. to train or fight with Al-Shabab.

Prosecutors had asked that Hassan remain in custody, but federal defender Manny Atwal said Hassan has been a model citizen since pleading guilty. She also said he has been honest and helpful to the court.

Hassan faces a maximum of 38 years in prison; no sentencing date has been set.

ASSOCIATED PRESS