Spy chief Jens Madsen said the gunman was known to intelligence services prior to the shooting and had probably acted alone. Police said he had a record of violence, gang-related activities and weapons possession.
Two civilians - a synagogue guard and a film-maker - were killed and five police were wounded in the two separate attacks in the Danish capital on Saturday and Sunday.
Witnesses said the gunman had fired up to 40 shots at a cafe hosting a free speech event with Swedish artist Lars Vilks, who has received death threats for depicting the head of the Prophet Mohammad on a dog.
The gunman then moved on to a nearby synagogue where the guard, protecting a young girl's confirmation, was gunned down.
On Sunday, thousands of Danes left a sea of flowers by the city's ornate 180-year-old synagogue.
"We are a small nation and such things don't happen here," 28-year-old student Frederikke Baastrup said, reflecting a widespread sense of shock in a country that prides itself on its reputation for safety and social tolerance.
Police cordoned off several sections of a predominantly immigrant neighbourhood and took away several people for questioning, witnesses said.
Danish media widely reported the gunman to be Omar Abdel Hamid El-Hussein. Reuters could not confirm his identity and police declined to comment.