The entrance of the Christmas market in Ludwigshafen, in western Germany, on Dec. 16. German prosecutors said they are investigating a 12-year-old boy’s alleged attempt to detonate a nail bomb at a Christmas market. (Uwe Anspach/Agence France-Presse via Getty Images)

German prosecutors are investigating an incident in which a 12-year-old boy allegedly plotted a nail bomb attack at a Christmas market in the southern city of Ludwigshafen, officials said Friday.

According to German media, investigators said that they think the boy, who holds dual German and Iraqi citizenship, was guided by a member of the Islamic State terrorist organization.

Focus news magazine reported Friday that the 12-year-old had planted a backpack containing a homemade bomb outside city hall in the center of Ludwigshafen on Dec. 5. A passer-by spotted it and called police, according to the magazine, and experts then partially detonated the device.

[ISIS is making its own ammunition almost as fast as it can fire it, report finds]

A previous attempt by the boy to set off a bomb at a local Christmas market Nov. 26 had failed, according to the Focus report. The device consisted of a preserving jar filled with powder from fireworks and fitted with nails.

According to local broadcaster SWR, the boy had been in contact with an Islamic State member and received instructions via the Telegram messaging service.

In a December news release, police had only confirmed that a jar filled with “pyrotechnical material” had been found and that it was believed to belong to a 12-year-old. There hadn’t been any danger to surrounding buildings, the release said.

In a brief statement to the media, Ludwigshafen Mayor Eva Lohse said the boy was “staying at a secure place and therefore does not currently present a ­danger.”

Stefan Biehl, a spokesman for Germany’s prosecutor general, told The Washington Post that an investigation into the case had been launched but refused to give more details because the probe is ongoing.

It is not the first such incident in Germany. Last week, police arrested two youths, ages 15 and 17, on suspicion of plotting an attack on a public institution in the south-central city of ­Aschaffenburg. In February, a 15-year-old girl stabbed a police ­officer in the neck at Hanover central station, inflicting life-threatening wounds. In both cases, the ­teenagers were believed to have been in contact or at least to have sympathized with the ­Islamic State.

But the age of the ­Ludwigshafen suspect has shocked the country and reinforced existing concerns about Islamist extremists targeting young people and inciting them to carry out violent acts.

“This news is startling everyone, of course,” government spokesman Steffen Seibert said at a news conference in Berlin.

Even though the suspect was born in Germany, the incident prompted Baden-Württemberg Interior Minister Thomas Strobl to call for stricter vetting of young immigrants, including fingerprinting and photographing children as young as 12.

Experts have long warned of potential terrorist attacks targeting one of Germany’s traditional Christmas markets.

Read more:

Suspect says Islamic State ordered 2015 high-speed train attack in France

Qatari sisters in a Bentley tear-gassed and robbed in $5 million Paris jewelry heist

Today’s coverage from Post correspondents around the world

Like Washington Post World on Facebook and stay updated on foreign news