Ahmed Hussein Mahamud, 26, is the 18th man charged in the government’s investigation into Somali men who are believed to have traveled from Minnesota to Somalia to take up arms with the terror group.

Mahamud was indicted in June on four counts, including conspiracy to provide material support to a foreign terrorist organization.

“My son is very sick and his health is not good,” Mahamud’s mother, Dhaqan Warsame, said through a translator after Thursday’s hearing. “He has a problem in his brain, a tumor in his brain.”

She said the tumor, which he has had since the age of 4, affects how he acts — even costing him a job because he forgot to show up for work. She said he has seizures if he does not take medication.

“How did he know what he do?” she said. “It’s very difficult to judge.”

She also said he has support from the larger Somali community. Dozens attended the hearing, spilling into the hall after the courtroom was filled.

Hodan Nur said her former neighbor is a good person, and when she heard about the charges against him: “It make me really dizzy, and I never believed he’d do bad things.”

US Magistrate Franklin Noel ruled Mahamud could be released to a halfway house in Minnesota under several conditions. Among them, he’s not allowed to travel out of state without approval.

Mahamud’s attorney, Rick Mattox, told the judge he hopes to modify his client’s conditions for release in the future.

Mattox had no comment when asked to confirm whether his client has a medical condition.

The indictment, filed in June, does not accuse Mahamud of traveling to Somalia, but it suggests he helped others who did. It says that from April 2009 to July 2009, Mahamud provided “money to Al-Shabaab and personnel to work under Al-Shabaab’s direction and control, knowing that Al-Shabaab has been designated as a foreign terrorist organization.”

It also says he conspired with others to provide people and financial resources to Al-Shabab, from an unknown date to the present. The US government says Al-Shabab has ties to Al-Qaeda.

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