The prosecutor's office in the southern city of Stuttgart confirmed on Thursday that the Syrian refugee was arrested on Sunday.

The 20-year-old man had failed to cross into Denmark a day earlier, they said.

Investigators believe he was planning to carry out an attack after discovering that he had obtained material which could be used to build weapons or bombs.

Spokesman Jan Holzner told the Reuters news agency that the suspect had been in Germany for some time but it was not clear when he entered the country.

Holzner did not identify the man and did not know whether the man had been granted asylum.

He had been living in a refugee shelter in southwest Germany.

"We have evidence that he sympathized with "Islamic State"," Holzner said.

It was not clear if the man had been in contact with IS members outside of Germany, he added.

No immediate threat

A statement later on Thursday by prosecutors gave additional details, saying there were no indications of a concrete threat.

German authorities are on high alert for possible Islamist attacks after two violent incidents linked to the militant group in July.

The first of these was when a man wounded several people in a knife and ax on a train close to the city of Würzburg in Bavaria

Days later, fifteen people were injured when a Syrian refugee blew himself up close to a music festival in the city of Ansbach, also in Bavaria.

Last month, Syrian refugee Jaber Albakr hanged himself after being arrested on suspicion of planning an attack on a Berlin airport.

German police have made dozens of other arrests of possible terror suspects during the year.

mm/jm (AP, Reuters)