A 20-year-old Moroccan-German suspect was detained by police in August after trying to buy weapons online.
German security officials said they have foiled a planned Islamist attack after arresting a man in Hamburg over the summer.
Authorities said the suspect had tried to buy a firearm and a hand grenade online and make explosives.
Hamburg’s top security official, Andy Grote, described the incident as “very, very serious”.
The 20-year-old German-Moroccan suspect — who has not been named — was taken into custody in August.
A judge ordered him to be kept in detention on suspicion of breaking firearms laws and indications that he planned to carry out an attack, Hamburg police said.
Officers searching his parents’ apartment following his arrest found Islamist propaganda videos and bomb-making instructions.
A separate search at a cousin’s home elsewhere in Hamburg last month uncovered substances used to make explosives and several hundred metal nuts and screws.
German news agency DPA reported that the suspect's father was known to police and had once held a position of responsibility at Hamburg’s al-Quds Mosque, where several of the plotters of the September 11 attacks met.