Danish police shot dead a gunman in Copenhagen on Sunday they believe was responsible for killing two civilians and wounding five police in separate attacks on a synagogue and an event promoting freedom of speech.
Prime Minister Helle Thorning-Schmidt said the shootings, which bore similarities to an assault in Paris in January on the offices of weekly newspaper Charlie Hebdo, were terrorist attacks.
A man died in Saturday's shooting at a cafe hosting Swedish artist Lars Vilks, who has received death threats for depicting the Prophet Mohammad. Vilks was unhurt. A security guard died in a separate attack overnight at a nearby synagogue.
"We've tasted the ugly taste of fear and impotence that terror wants to create," Thorning-Schmidt told reporters. "But as a society, we have answered back."
Police had released a photo of the suspect, dressed in a heavy winter coat and maroon mask. But the motivations of the gunman, who police said was armed with an automatic weapon, were not known.
Danish police had launched a massive manhunt with helicopters roaring overhead and an array of armored vehicles on the usually peaceful streets of Copenhagen.
Police said they shot dead the suspect near a train station in Norrebro, an area in Copenhagen not far from the sites of the two attacks. Police said he had fired on officers. Some local media said police raided an apartment in the area.
"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, entitled "Art, Blasphemy and Freedom of Expression", and praised Denmark's support for freedom of speech following the Paris attacks.
Witnesses said the envoy had barely finished his introduction when up to 40 shots rang out, outside the venue, as an attacker sprayed the cafe's windows with bullets.
Security experts 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.
Witnesses said police who were at the heavily-guarded venue fired back at the attacker. Vilks was taken to a back cold storage room for protection.
"The rather spare audience got to experience fear and horror - and tragedy. I can't say it affected me as I was well looked after," Vilks wrote in a blog post.
Hours later, shots were fired at a synagogue about a half hour's walk from the cafe. A man guarding the synagogue was shot in the head and died later. Two police officers were wounded.
"He was a member of the community, a fantastic guy," Rabbi Bent Lexner, Denmark's former chief rabbi, told Israeli Army Radio. "We are in shock. I am sitting now with the parents of the man killed. We didn't think such a thing could happen in Denmark."
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 became a target 10 years ago after the publication 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 blasphemous.
Vilks stirred controversy himself in 2007 with drawings depicting Mohammad as a dog, triggering numerous death threats.
He has lived under Swedish police protection since 2010 and two years ago, an American woman was jailed for 10 years in the United States for plotting to kill him.
Danish authorities have been on alert since three Islamist gunmen killed 17 people in three days of violence in Paris last month that began with an attack on Charlie Hebdo, long known for its acerbic cartoons on Islam, other religions and politicians.
Like other European governments, Scandinavian leaders have been increasingly concerned about the radicalization of young Muslims traveling to Syria and Iraq to fight alongside violent jihadist groups such as Islamic State.
Authorities have also been worried about possible lone gunmen like Anders Behring Breivik, the anti-immigrant Norwegian who killed 77 people in 2011, most of them at a youth camp run by Norway's ruling center Labour Party.
French Foreign Minister Laurent Fabius compared the Copenhagen attack to the Paris killings, told Europe 1 radio on Sunday: "I am struck by the similarities of this sequence. First an attack against freedom of speech, then an attack against Jews, and then the confrontation with the police."
After the synagogue shooting, Israeli Prime Minister Benjamin Netanyahu said such attacks would likely continue and Israel would welcome European Jews who choose to move to there.
French President Francois Hollande said Interior Minister Bernard Cazeneuve would go to the Danish capital later on Sunday.
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."