German prosecutors say they have handed terror charges to two alleged members of the Islamic State group who traveled to Syria via Turkey in May 2014.

Federal prosecutors said Thursday that 27-year-old Ayoub B. and 26-year-old Ebrahim H. B. — whose surnames were withheld under German privacy rules — have been charged with being members of a foreign terror organization.

B. allegedly underwent weapons training and later took part in fighting near Syria's Iraqi border.

Prosecutors said H. B. volunteered to carry out a suicide bombing in the Iraqi capital Baghdad, but the plan collapsed after some of the IS members he traveled with were arrested.

The men returned to Germany in late August and September last year.

They face up to 10 years in prison if convicted.