The man, who is from Syria, is believed to have planned to attack German soldiers in the city of Hof in Bavaria during their lunch break, according to prosecutors in Munich. The 27-year-old is said to have bought two 40-centimeter-long machetes with the intention of "killing as many as possible".
He is now suspected of preparing a terrorist offense.
A fierce debate about migration and crime has erupted in Germany after a knife attack in Solingen at the end of August, in which a Syrian IS sympathizer murdered three concert-goers. The attack follows a series of other high-profile knife attacks with perpetrators from Syria and Afghanistan, including in May, when a police officer was killed when an Afghan man attacked an Islam-critical market in Mannheim.
The attacks have led opposition leader Friedrich Merz (CDU) to demand a complete halt to refugee admissions from the two war-torn countries and long-term imprisonment of convicted criminals who do not have the right to stay in Germany, but who cannot be deported for various reasons.