The 18-year-old German-Iranian student, David Ali Sonboly, who killed nine people in a shooting rampage in Munich, Germany had been planning the attack for a year.
The 18-year-old lone gunman who killed nine people in a shooting spree in Munich before killing himself had been planning his crime for a year but chose his victims at random, officials said on Sunday.
Born and raised locally, the teenaged shooter opened fire near a busy shopping mall on Friday evening, triggering a lockdown in the Bavarian state capital.
"He had been preparing (the shooting) for a year," Bavarian police chief Robert Heimberger told a news conference.
The German-Iranian student, David Ali Sonboly, did not specifically choose his victims, Chief prosecutor Thomas Steinkraus-Koch said.
"It is not the case that he deliberately selected the people who he shot," he said.
The Munich attack is the third attack in Europe in just over a week in which 27 people were also injured, some seriously.
Officials said Saturday that the teenaged student, had a history of mental illness.
Investigators said they saw an "obvious link" between the killings and white supremacist Anders Breivik's massacre of 77 people in Norway exactly five years earlier.
German Chancellor Angela Merkel said on Sunday that Munich had suffered a "night of horror".
She said she was "mourning with a heavy heart" for those killed, and that the security services would do everything to ensure the public was safe.
Turkey's foreign minister said three Turkish citizens were among nine people killed in the Munich attack while Greece's foreign ministry said one Greek was among the dead. According to foreign media reports, there were also three Kosovo Albanian victims.
Fixated on mass killings
The deranged gunman was obsessed with mass killings who drew no inspiration from any militant group, police said on Saturday.
Seven of his victims were themselves teenagers, whom police said he may have lured to their deaths via a hacked Facebook account on what was the fifth anniversary of twin attacks by Norwegian mass murderer Anders Breivik that killed 77 people.
Bavarian police chief, Robert Heimberger, said Sonboly was carrying more than 300 bullets in his backpack and pistol when he shot himself.
Munich police witnessed the suicide at 8:30 p.m. local time (1830 GMT), said the police.
Following a police search of the attacker's room, where a book on teenage shooting sprees was discovered, Munich police chief Hubertus Andrae all but ruled out link to any militant group.
"Based on the searches, there are no indications whatsoever that there is a connection to Islamic State (DAESH) or to the issue of refugees, he told a news conference.
"Documents on shooting sprees were found, so the perpetrator obviously researched this subject intensively."
However, Interior Minister Thomas de Maiziere said it was also too early to associate the Munich shootings with Breivik, who in 2011 shot dead 69 attendees at a youth summer camp hours after murdering eight others by detonating a van bomb in Oslo.
But he told German public television the government would look carefully at its security measures once the investigation was completed to see if any changes were needed.
Fast-food invite via Facebook?
Police were investigating findings suggesting the Munich gunman invited people to a fast food restaurant at the mall via the Facebook account, Heimberger told the news conference.
"(He) said he would treat them to what they wanted as long as it wasn't too expensive - that was the invitation," Heimberger said. He added that this still needed to be verified, but there were many clues suggesting the attacker had set up the invitation and sent it or posted it online.
Pope Francis condemns attack
Pope Francis responded to recent acts of violence in Germany and Afghanistan, expressing his closeness to the families of the victims, and stressing the importance of prayer in the face of threats against "safety and peace."
"At this time, our spirit is once more shaken by the sad news relating to the deplorable acts of terrorism and violence which have caused suffering and death," the Pope said in an appeal after the weekly Angelus at the Vatican.
The attack came just four days after a 17-year-old asylum seeker went on a rampage with an axe and a knife on a train in Bavaria, a state south-east of Germany, injuring five people.