(Adds dropped word 'suspect' in headline)
* Police believe man they shot dead behind both attacks
* Two killed in attack on cultural event, synagogue
* PM promises to protect Jewish communities
By Sabina Zawadzki and Ole Mikkelsen
COPENHAGEN, Feb 15 (Reuters) - Police shot dead a 22-year-old Danish-born gunman on Sunday after he killed two people at a Copenhagen synagogue and an event promoting free speech in actions possibly inspired by an attack on the French satirical weekly Charlie Hebdo, authorities said.
Spy chief Jens Madsen said the gunman was known to intelligence services prior to the shooting and probably acted alone. Police said he had a record of violence, gang-related activities and weapons possession. They did not publish his name.
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.
Witnesses to the Copenhagen attacks said the gunman 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. Vilks was unharmed.
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 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 in a predominantly immigrant neighbourhood and took away several people for questioning, witnesses said.
Danish authorities have been on alert since Islamist gunmen killed 17 people in three days of violence in Paris in January that began with an attack on weekly Charlie Hebdo, long known for its acerbic cartoons on Islam, other religions and politicians.
"Denmark and France are the same nations, feeling the same sadness but also the same will to resist, fight and defeat terrorism," French President Francois Hollande said.
"They hit the same targets, they hit what we are, what we represent, the values of freedom, the rule of law, that all citizens, whatever their religion, should be able to enjoy," Hollande said.
Madsen said the attacks appear to have been inspired by the January attacks in Paris.
But police who had earlier released a photo of the suspect dressed in a heavy winter coat and maroon mask, said they did not believe he had received training in jihadist camps in the Middle East.
The man had two handguns on him when he was killed and the police search later found an automatic weapon that may have been used in Saturday's attacks.
The gunman's primary target was likely to have been the free speech event with Vilks.
Dozens of bullets were fired in quick succession, probably from an automatic weapon, according to a recording of the event obtained by Danish TV2.
Prime Minister Helle Thorning-Schmidt said the attacks were terrorism but said this was not the start of a war between the West and Islam.
"When you mercilessly fire deadly bullets at innocent people taking part in a debate, when you attack the Jewish community, you attack our democracy," Thorning-Schmidt said outside the synagogue. "We will do everything possible to protect our Jewish community."
Denmark became a target of violent Islamists 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's head on a dog, triggering death threats.
Israeli Prime Minister Benjamin Netanyahu said such attacks would likely continue and said Israel would welcome European Jews who choose to move to there.
Witnesses said French ambassador Francois Zimeray had just finished introducing the cafe event, entitled "Art, Blasphemy and Freedom of Expression", when the assailant opened fire.
The venue was heavily guarded by police, who fired back, but the attacker nevertheless escaped.
Vilks, sheltered on the floor of a cold room at the back of the cafe with one of the event's organisers.
"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.
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.
Like other European governments, Scandinavian leaders have been increasingly concerned about the radicalisation of young Muslims travelling 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 centre-left Labour Party. (Added reporting by the Copenhagen bureau, Niklas Pollard in Stockholm and Michel Rose in Paris; Writing by Alistair Scrutton, Balazs Koranyi; Editing by Jon Boyle and Stephen Powell)
Our Standards: The Thomson Reuters Trust Principles.