Police in Copenhagen say they have shot dead a man who opened fire on them close to the sites of two earlier attacks in the Danish capital.
They are investigating whether the man might be behind deadly shootings hours earlier at a cafe and near a synagogue.
In the first attack, one person was killed and two injured during a free speech debate in a cafe.
In the second, a Jewish man was killed and two police officers wounded near the city's main synagogue.
It was not immediately clear whether or how the shootings may have been connected.
Early on Sunday, police said they had been keeping an address under observation in the district of Norrebro, waiting for the occupant to return.
When he showed up, he noticed the officers, pulled out a gun and opened fire, police said. They returned fire and shot him dead.
Norrebro is a predominantly immigrant district of Copenhagen, about three miles (5km) away from the synagogue where the shooting took place just hours earlier.
Barrage of gunshots
The BBC's Malcolm Brabant in Copenhagen says the city has been abuzz with sirens and helicopters, amid fears that other attacks could be imminent.
Police have warned residents that it is not safe to be in the city centre, although they stress that there is no curfew in force.
A massive manhunt was launched after the first shooting, which took place during a free speech debate attended by a Swedish cartoonist.
An audio recording, obtained exclusively by the BBC, revealed the moments leading up to the attack.
One of the speakers at the debate, which took place at a cafe and concerned the limits of free speech, is suddenly interrupted by a barrage of gunshots.
Speaking to the BBC, witness Dennis Myhoff-Brink said: "People were trying to get to the doors, trying to get out of the room, hiding between or behind the tables and chairs, and some people were running out into the street."
Officials said the gunman made his getaway by car, and a black Volkswagen Polo was later found abandoned a short distance from the scene, police said.
Police released photographs showing the alleged attacker apparently wearing a purple balaclava and thick puffer jacket.
Hours later, a gunman opened fire on Krystalgade street, about 5km from the scene of the first attack.
A man was shot in the head and was later confirmed to have died, and two police officers suffered injuries to their arms and legs. The attacker is believed to have fled.
A Jewish community group quoted by AFP news agency later said that the man killed was Jewish and had been helping with a confirmation ceremony taking place inside the synagogue.
Police spokesman Allan Wadsworth-Hansen said the first shooting was likely terror-related and "it makes a perfect sense to investigate it [the second shooting] down the same route".
Prime Minister Helle Thorning-Schmidt described the first attack as a "politically motivated" act of terrorism.
Cartoonist Lars Vilks, who has faced death threats over his caricatures of the Prophet Muhammad, said he believed he was the intended target of the attack. He was unhurt.
The French ambassador, Francois Zimeray, was also present during the attack.
A description of the debate at the cafe asked whether artists could "dare" to be blasphemous in the wake of attacks by Islamist gunmen in Paris last month against satirical magazine Charlie Hebdo.
In the French attacks, two gunmen opened fire at Charlie Hebdo's office, shooting dead 12 people. Two days later, a suspected accomplice of the militants took hostages at a Jewish shop, killing four of them.
All three attackers were eventually shot dead by police and security services.