The boy, a German citizen of Iraqi heritage, attempted to blow up the device at the Ludwigshafen Christmas market on November 26th. When the device failed to detonate he gave up, before trying again on December 5th, prosecutors said on Friday.
This time he took the explosive device, hidden in a rucksack filled with nails, and placed it in a bush near the town hall.
Fortunately a pedestrian spotted the bag and alerted police, who then had specialists carry out a controlled explosion, Focus magazine reported on Thursday, citing security sources.
The 12-year-old, born in the town in Rhineland-Palatinate in 2004, had been radicalized and was encouraged to carry out the attack by an as-yet unknown member of the Isis terror group, according to Focus.
Public broadcaster Suedwestrundfunk, also citing unnamed security sources, said the boy was thought to have received instructions from the Isis via the encrypted instant messaging service Telegram.
According to an earlier report by police investigators, the powder in the homemade bomb had been created out of the ingredients of fireworks and sparklers and was flammable but not explosive.
Local prosecutor Hubert Ströber told AFP that to call the device a bomb would be an exaggeration. He said that although the powder was combustible, it was unclear whether it would have exploded.
The child, who cannot face a German court because he is aged under 14, was detained and placed into a juvenile care facility, said Focus.
City mayor Eva Lohse said he "is currently staying at a secure place and therefore presents no public threat".
Federal prosecutors are however investigating the possibility that a terror network supported the attempted attack.
Tunisian Isis suspect with 'mission' arrested
Also on Thursday, prosecutors announced the arrest of a Tunisian man suspected of planning an unspecified mission for the Isis jihadist group.
The 24-year-old identified only as Charfeddine T. had joined Isis before he arrived in Germany in October 2015, the prosecutors' statement said.
Prosecutors had obtained an arrest warrant against him on Wednesday, accusing him of membership of a foreign terrorist organisation.
The suspect had been in contact with an Isis member in Syria responsible for running the group's operations abroad and had requested permission to carry out his mission, the statement said.
"Investigations so far have not confirmed whether it was to carry out an attack," said the federal prosecutors.
Germany has been spared the kind of large-scale jihadist atrocities that hit Paris and Brussels.
But it was shaken by two assaults claimed by Isis and carried out by asylum seekers this year -- an axe rampage on a train that injured five, and a suicide bombing that wounded 15 people.
Police said in October they had foiled a plot by a Syrian refugee to bomb one of Berlin's airports.