Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A lone 18-year-old gunman is believed to have carried out a shooting rampage near a shopping center in Munich, Germany, killing at least nine people before later apparently killing himself, police said.

The shooting attack at a McDonald's attached to the Olympia Einkaufszentrum shopping center at around 5:50 p.m. local time (11:50 a.m. ET) Friday led authorities to lock down the city. Public transportation was shut down and residents were warned to stay away from public places.

"Careful all-clear," Munich police said on Twitter early Saturday. "As part of our manhunt we found one person that killed himself. With high probability it is the suspect, who — according to the present state of investigation — acted alone."

The gunman was an 18-year-old German-Iranian from Munich who had been living in the city for more than two years, Munich Police President Hubertus Andrae said. A motive is unknown, he said.

Sixteen people were injured, three of whom were critically wounded, police said. Authorities said children were among the killed and wounded.

We found a man, who killed him himself.

We assume, that he was the only shooter. #gunfire #munich — Polizei München (@PolizeiMuenchen) July 22, 2016

The gunman opened fire outside a McDonald's, then inside and continuing the shooting rampage inside the mall, Andrae said. The gunman, who was not identified, was found dead at around 8:30 p.m. and police believe he likely killed himself.

Munich police spokesman Marcus da Gloria Martins said in a press conference earlier that "we are operating on the premise of a terrorist attack," but Andrae said later that links to terror had not been established.

German police initially said there could be as many as three gunmen. Cars racing from the scene were later identified and determined not to be related to the shooting spree, Andrae said.

Police said witnesses described multiple suspects wielding long guns, but Andrae said that claim was unfounded. He said a handgun was used in the shooting. The suspected gunman did not have a police record, Andrae said.

Special forces from Bavaria, other German states and from federal police were on duty in the city, Munich police said. Around 2,300 security personnel were deployed, Andrae said. The National Security Cabinet will meet Saturday.

In the aftermath of the shooting, police received several reports of other shootings and hostage taking scenarios during the course of evening, but none turned out to be real, Andrae said. The U.S. State Department warned Americans to shelter in place amid the uncertainty.

All Munich public transportation — subway, bus, and tram — was shut down after the shooting, and police tweeted in several languages pleading for the public to "please avoid public areas." By shortly after 1 a.m. Saturday local time, police said transportation was back to normal.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Special police forces prepare to search a neighboring shopping center outside the Olympia mall in Munich on July 22. Sebastian Widmann / AP

Thamina Stoll, a Duke University student from Munich, was heading to the shopping center with her family when she saw people fleeing the area.

"People were running and telling us not to go to the shopping mall. They were in shock. They weren't able to talk anymore," Stoll told NBC News. Stoll said she let a family fleeing the scene take shelter in her grandmother's nearby apartment as helicopters circled above the area.

The sprawling two-story Olympia Einkaufszentrum opened in 1972 during the Summer Olympics in Munich, according to the mall's website.

"It is terrible and sheer inconceivable what happened in Munich. We are mourning the victims and are in our thoughts with the relatives," German Interior Minister Thomas de Maiziere said in a statement. "We can unconditionally rely on the Bavarian security forces. In these hours our special thanks goes out to them."

President Barack Obama was briefed on the situation and pledged to provide Germany any assistance it may require.

"The United States condemns in the strongest terms the apparent terrorist attack that has claimed innocent lives in Munich, Germany," the White House said in a statement.

"We still do not know all of the facts, but we do know that this heinous act has killed and injured multiple individuals in the heart of one of Europe’s most vibrant cities," the statement said. The U.S. State Department later issued a statement condemning the attack, but that statement did not use the word terrorism.

Europe has been on edge following terror attacks in France and Belgium. The shooting is the second attack in Germany's Bavaria region this week.

On Monday, a 17-year-old Afghan injured four people with an ax on a German train near Wurzburg-Heidingsfeld in northwest Bavaria before he was shot dead. Authorities later found what appeared to be a hand-painted flag of the terror group ISIS in his room.

In May, a man with a knife killed one person and wounded at least three others at a train station in Mainz, near Munich.

The mall attack put other cities on alert.

The New York Police Department's counterterrorism unit tweeted that it was "monitoring events unfolding in Munich." And the United Kingdom's Foreign Ministry urged Britons to "avoid this location and follow the advice of local authorities" on its travel advisories page.

The U.S. Consulate in Munich tweeted, "Closely follow police instructions and shelter in place." The U.S. State Department urged Americans in Munich to contact loved ones.

Starwood Hotels locked down its six hotels in Munich, and increased security at all of its properties in Germany, the company said. Belgium's prime minister, Charles Michel, said he was "profoundly shocked" by the violence.

German vice-chancellor and economic minister Sigmar Gabriel called the violence "shocking" and said now is not the time for speculation. "Thoughts are with the victims," Gabriel said on Twitter.

U.S. Democratic presidential candidate Hillary Clinton said on Twitter: "Monitoring the horrific situation in Munich. We stand with our friends in Germany as they work to bring those responsible to justice."

Republican presidential nominee Donald Trump said in a statement that his thoughts are with those affected and added, "the rise of terrorism threatens the way of life for all civilized people."

Flags at half mast for #Munich. Still waiting for a clearer picture of the entire situation. pic.twitter.com/3uQXjmm8QO — German Embassy (@GermanyinUSA) July 22, 2016

Obama said Friday that "our hearts go out to those who may have been injured."

"It's still an active situation and Germany is one of our closest allies, so we are going to pledge all the support they may need in dealing with these circumstances," he said.