BERLIN (AP) – A 37-year-old German man who fought for the Taliban in Afghanistan has been convicted of membership in a terrorist organization.

The dpa news agency reported Monday that Thomas K. was sentenced in Duesseldorf state court to six years in prison.

His last name wasn’t given in line with German privacy laws.

Prosecutors said he started fighting for the Taliban in 2013 and continued until he was captured in February. He was returned to Germany in April.

When he was charged, prosecutors said he prepared explosives, got ready for a suicide attack and worked on a propaganda video aimed at German radicals. He also allegedly had himself filmed participating in a failed mortar attack on an Afghan army base.