A man wounded several people with a knife in the southern German city of Munich on Saturday and officers are looking for the assailant, police and the fire department said. They mainly had superficial stab wounds and in at least one case had been hit.
About three hours later, police arrested a man matching a description they had issued based on witness reports. He was wearing grey pants, a green jacket and a backpack.
Officials believe that the suspect - who had a previous police record - has psychological problems.
There was no immediate word on a possible motive.
The authorities previously said they had deployed "all available police forces" to search for the attacker.
Twin Taliban attacks at Afghanistan army base kill dozens
The Taliban claimed responsibility for the attack, saying in a text to media outlets that 60 Afghan security forces were killed. The battle ended with a US airstrike that killed nine Taliban fighters, North Atlantic Treaty Organisation officials said.
"We have arrested a suspected person".
The assailant fled from the scene on a Bicycle.
The 33-year-old suspect began indiscriminately stabbing passers-by in the Haidhausen area, east of downtown Munich, targeting eight people in all, including a 12-year-old child, at different sites.
The police called on people living in the Rosenheimer Platz area to remain indoors and avoid the area, as well as the areas near the Ostbahnhof railway station and Ostpark.