A German soldier suspected of planning a terror attack has been arrested, prosecutors in Frankfurt said on Thursday.

The 28-year-old, whose name was not provided due to privacy laws, was arrested by police during training at the Bundeswehr base in Hammelburg, Bavaria. Police also searched 16 locations in Germany, Austria and France that yielded evidence.

Investigators believe the lieutenant was motivated by a "xenophobic background" to plan an attack, possibly on migrants and refugees.

Prosecutors said the man hid a loaded weapon in a bathroom at Vienna airport in January. He was then briefly arrested by Austrian police when he returned in February to retrieve it.

They later released the soldier due to insufficient evidence. However, the suspect's fingerprints indicated he had in late 2015 used an alias to falsely register as a Syrian refugee in Germany. In early 2016, he applied for asylum. He was subsequently granted accommodation and even received aid money.

Watch video 12:02 Share Germany in the Crosshairs of Terrorism Send Facebook google+ Whatsapp Tumblr linkedin stumble Digg reddit Newsvine Permalink https://p.dw.com/p/2ZUib Germany in the Crosshairs of Terrorism

The soldier apparently didn't attract the attention of authorities, even though he spoke French but no Arabic. During this time he was stationed in Illkich, France, where there is a joint German-French brigade.

Prosecutors believe the soldier planned to use the weapon from the Vienna airport to carry out a "serious state criminal offense." The weapon was illegal and not obtained from the Bundeswehr.

Police also arrested a 24-year-old student in the soldier's home town of Offenbach, near Frankfurt. Authorities believe he has a far-right extremist background and found items prohibited under weapons and explosives laws in his home.

Investigators are uncertain about all motives, but they have not ruled out the two men sought to carry out an attack in order to blame it on refugees.

The Military Counterintelligence Service (MAD) is currently investigating 275 cases of right-wing extremism within the Bundeswehr, in addition to dozens of cases of suspected radical Islamists and left-wing extremists.

cw/rt (AFP, dpa)