Police in Munich
Police officers stand guard outside the main train station following a shooting rampage at the Olympia shopping mall in Munich, Germany July 22, 2016. REUTERS/Michael Dalder

A 15-year-old boy was arrested in Baden-Wuerttemberg on suspicion of planning to carry out a school shooting, police said.

The boy had reportedly been in contact online with Ali David Sonboly, the 17-year-old who shot dead nine people then killed himself in Munich on Friday.

Police said on Wednesday that Sonboly, a German citizen of Iranian heritage, was a far-right extremist, who boasted of sharing the same birthday as Adolf Hitler.

Officers had been alerted to the 15-year-old's plans by a private individual, who had been carrying out independent research on Sonboly. The individual found drawings and photos published by the 15-year-old suggesting he was planning an attack, Baden Wuerrtemberg police said in a statement.

In a search of the youth's home in Ludwigsburg, near Stuttgart, officers found "extensive evidence, including a larger number of small-calibre cartridges, several knives and daggers, evacuation plans of his school, and a large amount of chemicals, materials and instructions for making explosives," police said in a statement.

Under interrogation, the boy admitted that he had planned an attack, but had changed his mind and did not intend to carry it out.

The boy is being held at a youth psychiatric facility.