The slain gunman behind two deadly shooting attacks in Copenhagen was released from jail just two weeks ago and might have become radicalized there last summer, a source close to the Danish terror investigation told The Associated Press on Monday.

Two Danish sources close to the investigation confirmed to the AP that the slain gunman was named Omar Abdel Hamid El-Hussein. The sources spoke on condition of anonymity because Copenhagen police have not named the gunman, who they said was a 22-year-old Dane. Several Danish media have already named him.

One source told the AP that El-Hussein had been in pre-trial detention for a long time but was released two weeks ago. He also said the corrections authority had alerted Danish security service PET last year after they noticed worrisome changes in El-Hussein's behaviour. He wouldn't elaborate.

The weekend attacks in Copenhagen killed two people and wounded five police officers.

The news about the suspected gunman came as Danes mourned the two victims of the country's first fatal terror attacks in 30 years — and, in an unusual development, some also put flowers at the spot where police killed El-Hussein.

While a Danish court on Monday jailed two suspected accomplices of El-Hussein's for 10 days, the prime minister insisted there were no signs the gunman had any links to a wider terror network.

The suspects arraigned Monday were accused of helping the gunman evade authorities and get rid of a weapon during the manhunt that ended early Sunday when the attacker was killed in a shootout with a SWAT team, said Michael Juul Eriksen, the defence attorney for one of the two suspects.

Danish Prime Minister Helle Thorning-Schmidt told reporters Monday that the gunman's choice of targets suggests the attacks were acts of terrorism.

Denmark Shots

An undated police handout image of Omar Abdel Hamid El-Hussein, the slain gunman in the deadly Copenhagen attacks. (Associated Press)

"We have no indication at this stage that he was part of a cell," she said. "But we will of course in the coming time evaluate our fight against radicalization. We are already doing a lot."

Two people were killed in the weekend attacks, including a Danish filmmaker attending a free speech event and a Jewish security guard shot in the head outside a synagogue in Copenhagen. Five police officers were wounded in the attacks. Police said Monday they are in good condition and are expected to be released from hospital this week.

"I want to underline that this is not a conflict between Islam and the West," Thorning-Schmidt said. "This is not a conflict between Muslims and non-Muslims. This is a conflict between the core values of our society and violent extremists."

Authorities have said the gunman had a history of violence and gang connections. Denmark's security service said he may have been inspired by the terror attacks by Islamic extremists in Paris that killed 17 people.

Jailed for stabbing on subway

Danish media are reporting El-Hussein was jailed for stabbing a 19-year-old man in the leg on a Copenhagen subway train in November 2013 and that he was released from jail in January.

Investigators on Monday released more information about the gunman's movements between Saturday's attacks on a cafe, and another outside a synagogue.

Police spokesman Joergen Skov said the gunman visited an internet cafe late Saturday, about 6½ hours after the first attack. Police raided the facility on Sunday and detained four people, including the two men arraigned on Monday, Skov said. The other two were released.

Denmark Shots

Former Chief Rabbi Bent Melchior, left, embraces Paris Mayor Anne Hidalgo with French Chief Rabbi Moise Lewin, centre, during a visit the synagogue in Copenhagen on Monday. (Stine Bidstrup/Associated Press)

Investigators released new images of the suspect and asked witnesses who had seen him enter or leave the internet cafe to contact police.

"We are of course interested in whether he was alone and whether he was carrying anything and in which direction he went," Skov said.

Denmark's red-and-white flag flew at half-staff from official buildings across the capital Monday. Mourners placed flowers and candles at the cultural centre where documentary filmmaker Finn Noergaard, 55, was killed and at the synagogue where Dan Uzan, a 37-year-old security guard, was gunned down.

Thousands at memorials

There was also a smaller mound of flowers on the street at the location where the gunman was slain, which critics said was an insult to his victims. Ozlem Cekic, lawmaker of the left-wing Socialist People's Party, called it "a huge assault on the Danish population."

The prime ministers of Denmark and Sweden were expected to join thousands of people at memorials in Copenhagen on Monday evening.

Denmark has been targeted by a series of foiled terror plots since the 2005 publication of 12 caricatures of the Prophet Muhammad in the newspaper Jyllands-Posten. The cartoons triggered riots in many Muslim countries and militant Islamists called for vengeance.

One of the participants in the free speech event targeted Saturday was Swedish artist Lars Vilks, who caricatured the prophet in 2007. Vilks, who was whisked away by his bodyguards and was unharmed, told The Associated Press he thought he was the intended target of that attack.

'Our cities are symbols of democracy, Paris and Copenhagen.' - Paris Mayor Anne Hidalgo

Other participants said they dropped to the floor, looking for places to hide as the shooting started. The gunman never entered the cultural centre but sprayed it with bullets from outside in a gun battle with police.

World leaders, including British Prime Minister David Cameron, German Chancellor Angela Merkel and UN Secretary-General Ban Ki-moon, condemned the Copenhagen attacks. 

Denmark Shots

People lay flowers outside a synagogue where a a guard was killed. (Rumle Skafte/ Associated Press)

French President Francois Hollande visited the Danish Embassy in Paris on Sunday and Paris Mayor Anne Hidalgo was in Copenhagen on Monday in a show of solidarity.

"The terrorist attacks have the same causes in Paris and Copenhagen," Hidalgo said. "Our cities are symbols of democracy, Paris and Copenhagen. We are here and we are not afraid."

Denmark's last terror attack with a deadly outcome took place in 1985, when a bomb exploded outside the Copenhagen office of airline North West Orient, killing a 27-year-old Algerian tourist.

With files from Reuters