Police searched for attackers, thinking there might be three, and found a man who'd killed himself on a side street near Olympia shopping mall, police Chief Hubertus Andrae said.
Based on surveillance video and witness statements, police concluded he was the sole gunman, Andrae said.
The unidentified attacker was an 18-year-old German-Iranian who had lived in Munich for more than two years.
The man was not known to police and his motives are unclear, authorities said. No group has claimed responsibility.
Many children were among the casualties. Police said 16 people remain hospitalized.
The shooting comes as recent terror attacks have put Europe on high alert.
This week, a teenager who said he was inspired by ISIS stabbed passengers on a German train
before police shot him dead. Only eight days earlier, 84 people were killed when a man drove a large truck through a Bastille Day crowd in Nice, France.
The gunman started shooting at a McDonald's across from the Olympia mall about 5:50 p.m. (11:50 a.m. ET), Andrae said.
Children unable to run away
A witness who will only be identified as Lauretta told CNN her son was in a bathroom with a shooter at the restaurant.
"That's where he loaded his weapon," she said. "I hear like an alarm and boom, boom, boom... And he's still killing the children. The children were sitting to eat. They can't run."
Lauretta said she heard the gunman say, "Allahu Akbar," or God is great. "I know this because I'm Muslim. I hear this and I only cry."
The gunman moved across the street to Olympia Mall, which is adjacent to the site of the 1972 Olympics. Located in a middle-class neighborhood in northern Munich, the mall is the city's biggest shopping cente and is a popular destination for shoppers on Friday nights, German lawmaker Charles Huber told CNN.
Lynn Stein, who said she works at the Jack Wolfskin store in the mall, said she heard six of seven shots.
"People were very confused, and they were running and they were screaming," she said. She saw someone lying on the floor of a store who appeared to be either dead or injured. "There's a woman over them, crying."
Profane exchange with a witness
Many citizens posted photos and video of the panic and the shooting on social media, including a profanity-filled verbal exchange between a man who matches the description of the Munich shooter and a witness.
The exchange, recorded on two different camera phones, captured an intense conversation that ends in gunfire. The man who appears to be a shooter said insulting things about Turks, did not espouse jihadist ideology and spoke with a German accent.
Police, thinking up to three gunmen might be on the loose, launched a manhunt, putting the city on virtual lockdown.
Police urged residents to stay in their homes. Citizens took to social media to offer help, with one woman tweeting: "Who is stranded in Sendling and shelter needs, PM me and come over"
Shoppers and people on the street stampeded. Thamina Stoll told CNN she was with her grandmother, who lives about three minutes away from the mall, and saw crowds sprinting down the sidewalk.
"There were like 50 people running towards our house to seek shelter, and there was a helicopter circling above us for about 20 minutes and sirens," she said. " And there's still people walking on the streets. They're confused, and nobody knows what's really going on."
At 8:30 p.m., police found a man who took his own life and decided he was the lone gunman, Andrae said.
The investigation will not yield quick answers, he said.
"We have to investigate everything via third person as we cannot question the perpetrator now," he said.
Merkel meeting with security officials
Germany increased security throughout the nation.
Enhanced police patrols were deployed to the Austria-German border, a spokesperson for the Austrian Ministry of Interior told CNN. Special forces from Bavaria and surrounding federal states were brought in to Munich as reinforcements during the search.
Chancellor Angela Merkel called a security council meeting for Saturday.
Foreign leaders expressed sympathy for the victims.
President Barack Obama condemned the attack, as did U.S. Secretary of State John Kerry. In a statement, Kerry said, "We are in close contact with German officials and stand ready to provide any and all assistance requested by our close friend and ally Germany in this time of crisis."
The U.S. military began a count of all its personnel -- some 62,000 -- and their dependents throughout Europe to confirm their safety.