The prime minister described the first shooting, which bore similarities to an assault in Paris in January on the office of weekly newspaper Charlie Hebdo, as a terrorist attack.
Two civilians died in Saturday's attacks and five police were wounded.
One man died in the first shooting, in a cafe hosting Swedish artist Lars Vilks, who has been threatened with death for depicting the Prophet Mohammad in cartoons. Another died in an attack on a synagogue close by.
Islamist gunmen attacked a Jewish supermarket in Paris two days after the Charlie Hebdo attack.
Danish police had launched a massive manhunt with helicopters roaring overhead and an array of armoured vehicles on the usually peaceful streets of Copenhagen.
By 0500 GMT, police said they had fired shots and later confirmed they killed a man in Norrebro, an area in Copenhagen not far from the sites of the two attacks.
"We assume that it's the same culprit behind both incidents... that was shot by the police," Chief police inspector Torben Molgaard Jensen told reporters.
French ambassador Francois Zimeray attended the cafe event and praised Denmark's support for freedom of speech following the January attacks in Paris.
Witnesses said the envoy had barely finished an introduction to the meeting when up to 40 shots rang out, outside the venue, as an attacker tried to shoot inside.
Police said they considered Vilks, the main speaker, to have been the target. A 55-year-old man died as a result of that shooting, police said early on Sunday.
"We feel certain now that it was a politically motivated attack, and thereby it was a terrorist attack," Prime Minister Helle Thorning-Schmidt told journalists, speaking on Saturday close to the site of the cafe.
Hours later, during the night, shots were fired at a synagogue in another part of the city, about a half hour's walk away from the cafe. A man was shot in the head, and was later confirmed to have died. Two police officers were wounded.

Latest News from World News Desk