Police say the Munich gunman was an 18-year-old German Iranian who had been living in the city.
Munich police said the teenager’s motive was “completely unclear”.
“The perpetrator was an 18-year-old German-Iranian from Munich,” police chief Hubertus Andrae told reporters after the massacre.
He had lived in the city “for a while”, Mr Andrae said.
“The motive or explanation for this crime is completely unclear,” the officer said.
Mr Andraes said that the body of the attacker was found about two and half hours after the shooting began.
His identity was determined based on the evaluation of witness statements and closed circuit television.
The body was found in a side street, not far from the shopping mall where much of the shooting happened.
Speculation about the gunman’s motives ranged from a right-wing extremist attack to an assault inspired by Islamic State.
Some witnesses describe hearing him yelling anti-foreigner insults before opening fire outside the McDonald’s restaurant, near to the mall.
In a later conversation with a witness, recorded on a mobile phone, the attacker said he is a German citizen.
Other media reported that the gunman had been bullied for “several years” and was seeking revenge.
Two others who fled the area quickly were investigated but had “nothing to do with the incident”.
Ten people, including the gunman, were killed.