The shooter was later found dead a few hundred metres from the Islamic Centre where the crime took place, and is believed to have killed himself.
Police had already been searching for him in connection with the discovery of a body on Sunday morning in a park in Zurich.
The victim in the park, also 24, died after being stabbed several times, said police.
He knew his attacker.
In the course of their investigations police established that the gunman was also responsible for the stabbing in the park.
No motive for the shooting or the stabbing has yet been discovered, however there is no indication of any connection to terrorism, said Lentjes Meili.
She added that the attacker may have had links to the occult.
“Corresponding symbols have been found at his home,” she said.
Lentjes Meili said the man had a legal permit for the gun he used in the shooting, and that it remained unclear if he was suffering from mental problems.
Investigators believe that the shooter lived alone.
He had been working at an undisclosed shop, but had quit his job last Friday, Lentjes Meili said.
Prosecutor Françoise Stadelmann told the media that the three victims from the Islamic Centre shooting have been operated on in hospital and are out of danger.