The teen killer who gunned down nine people in a Munich rampage Friday did so as revenge for years of bullying, he appears to admit in a chilling caught-on-camera exchange.

The brief footage, posted to Twitter, is believed to show David Ali Sonboly on top of a parking garage as a man slings profanity at him and asks him what he is doing.

“Because of you I was bullied for seven years and now I have to buy a gun to shoot you,” a person believed to be Sonboly, 18, says in the video.

It’s unclear whether Sonboly knew the man shouting at him. The German-Iranian student opened fire at a McDonald’s and a mall Friday, killing nine and injuring at least 27 others before committing suicide.

Sonboly may have hacked a young girl’s Facebook and posted a message about a food giveaway at the McDonald’s to lure more victims there, authorities said.

In the footage, a man is hurling profanity at Sonboly, who is dressed in black and standing at the top level of a parking garage.

“ You f—g -sshole you,” the man yells, telling the shooter, “You c- -t you, you’re a c- -t,” according to English transcripts provided by The Guardian and posted to a web site called Pastebin.com.

The man shouted at the teenager that “your head isn’t right,” adding, “Sh-t, f—–g foreigners!”

Sonboly replied, “I am German.”

The man continues to curse at Sonboly, who orders him to “ stop filming.”

“I was born here,” Sonboly assures the man, who asked him, “Yeah and what the f- -k you think you’re doing?”

Sonboly says he grew up in Munich in “Hartz 4,” an unemployment benefits area of Germany.

After about a minute, Sonboly appears to fire shots at the man who is filming him from a nearby building.

He had 300 bullets with him when he began his slaughter, said Munich Police Chief Hubertus Andrae, who said there were “no indications whatsoever” that Sonboly had links to ISIS or was motivated by politics.

The teen was being treated for depression, and had an obsession with mass shootings such as that of white supremacist Anders Behring Breivik, who killed 69 people at a summer camp in Norway.