The teenager shot dead by a police officer with a submachine gun in Dortmund on Monday was in a psychiatric ward shortly before the crime.
He went there himself because of psychological problems, said a spokesman for the Dortmund public prosecutor's office on Wednesday.
The "image" had previously reported about it.
The police were called on Monday afternoon to a youth welfare facility to which the 16-year-old had been assigned.
According to the prosecutor, he was an unaccompanied minor refugee from Senegal.
According to prosecutors, the teenager had a knife with him.
What he originally intended to do with it
-
whether he wanted to hurt himself or others as well
-
is still unclear.
There were suicidal intentions in the room, said the spokesman for the public prosecutor's office.
The teenager is said to have attacked the police officers with a knife.
The officers used tear gas and tasers.
Finally, a 29-year-old police officer shot six times with a submachine gun.
The 16-year-old was shot five times and died in hospital.