German prosecutors say they have filed terror charges against two men they say are 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.

The 27-year-old allegedly underwent weapons training and later took part in fighting near Syria's Iraqi border.

Prosecutors said the 26-year-old 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.