A former California college student has pleaded guilty to charges of aiding a terrorist organization after earlier arguing he was entitled to immunity because he hooked up with the kind of Syrian rebels the U.S. has backed.

Twenty-five-year-old Aws Mohammed Younis Al-Jayab admitted in a plea agreement Wednesday to flying from Chicago to Turkey in 2013, then traveling to Syria. The agreement says he joined Ansar Al-Islam, a precursor to the Islamic State group.

The agreement calls for a prison sentence of up to 15 years.

Al-Jayab told the judge he wanted to fight the Bashar al-Assad regime, but acknowledged the group he was joining engaged in terrorist actions.

He returned to the U.S. in 2014 and settled in Sacramento, California, where he enrolled at a community college.