Mattson, who works for the Swedish Economic Crimes Bureau, is active in the fight against organized crime, police sources said. Earlier this year, he appeared at a press conference following a raid on a number of address connected to the Bandidos motorcycle gang.
Shortly before 1am on Friday, shots were fired through the window of the prosecutor's fourth floor apartment in central Malmö.
There was one person in the apartment at the time though the prosecutor himself was not present at the time of the shooting. There have been no reports of any injuries.
Chief prosecutor Sven-Erik Alhem said the attack was most likely part of a larger plan.
He recalled the bomb attack on the home of prosecutor Barbro Jönsson in Trollhättan in November.
"It may be that organized criminals are trying to strengthen their own influence on society through an escalation of violence and threats," he said in a statement to news agency TT.