A 12-year-old German-Iraqi boy tried to blow up a Christmas market in the town of Ludwigshafen, prosecutors say.
He left a rucksack with explosives which failed to detonate in November, and put another explosive device by the town hall a few days later, they say.
But a member of the public alerted the police, and no-one was injured.
The 12 year old - who is now in custody - is thought have been recently radicalised and to have links with the so-called Islamic State group.
Focus magazine cited security and judicial sources as saying the boy was "strongly radicalised" and apparently instructed by an unknown IS member.
The Federal Public Prosecutor's Office declined to comment on a possible IS link, but confirmed officials were investigating the case.
Public Prosecutor Hubert Stroeber said the boy left a backpack containing a home-made nail bomb at the Christmas market in Ludwigshafen, in the state of Rhineland-Palatinate, on 26 November, but the device did not go off because the detonator apparently failed.
The second device near the city's town hall, placed on 5 December, was discovered by an "informant" and specialists defused it, Mr Stroeber said.
The boy was born in Ludwigshafen to Iraqi parents in 2004.
Prosecutors said no formal proceedings would be launched against him, because he is below the age of criminal responsibility.
Last Thursday, German police arrested two teenagers aged 15 and 17, accused of plotting a terror attack on a public institution in Aschaffenburg, in north-western Bavaria. Police found Islamic State flags and propaganda material in their homes.
Germany suffered a spate of attacks in the south of the country over the summer.
Ten people were killed and dozens more injured in separate gun, bomb, axe and machete attacks.
The authorities say they were not linked, and one of them was not terror-related.
But the wave of violence has made a nation already on edge after a huge influx of refugees even more nervous.