Danish police shot and killed a man in Copenhagen on Sunday they believe was responsible for two deadly attacks at an event promoting freedom of speech and on a synagogue.
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 armored 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.
In Paris on Jan. 17, brothers Cherif and Said Kouachi burst into the office of the Charlie Hebdo newspaper and opened fire in revenge for its satirical images of the Prophet Mohammad.
In all, 17 people were killed over three days of violence in France.
European Council President Donald Tusk called Saturday's attack "another brutal terrorist attack targeted at our fundamental values and freedoms, including the freedom of expression."
Helle Merete Brix, organizer of the event at the cafe, told Reuters she had seen an attacker wearing a mask.
"The security guards shouted 'Everyone get out!' and we were being pushed out of the room," Brix said.
"They tried to shoot their way into the conference room ... I saw one of them running by, wearing a mask. There was no way to tell his face."
Denmark itself became a target after the publication 10 years ago of cartoons lampooning the Prophet Mohammad, images which led to sometimes fatal protests in the Muslim world.
Many Muslims consider any representation of the Prophet Mohammad blasphemous.
Vilks stirred controversy himself in 2007 with his drawings depicting Mohammad as a dog, triggering numerous death threats.
He has lived under the protection of Swedish police since 2010. Two years ago, an American woman was sentenced to 10 years in prison in the United States for plotting to kill him.
French President Francois Hollande said Interior Minister Bernard Cazeneuve would go to the Danish capital later on Sunday.