Two girls were left with severe injuries after they were attacked on their way to school in the small German town of Illerkirchberg.

The attacker was wielding a knife, German daily Bild reported.

A police spokesperson confirmed two girls suffered injuries in the attack on Monday morning.

The attack took place in Illerkirchberg, a town of around 5,000 people west of Munich.

After tending to the severely injured girls, police found a suspect had fled into a nearby building, Wolfgang Juergens, spokesperson for police in the German city of Ulm, told local broadcaster SWR.

The people inside the building were taken into custody, he said.

He did not confirm how many people had been found or whether any of them were the suspected attacker.

Police are yet to say if they suspect a motive for the attack.