The shootings, which Prime Minister Helle Thorning-Schmidt called acts of terrorism, sent shockwaves through Denmark and have been compared to the January attacks in Paris by Islamist militants that killed 17.
“The two men are charged with helping through advice and deeds the perpetrator in relation to the shootings at Krudttonden and in Krystalgade,” the police said in a statement, referring to the location of the two attacks.
Police had no further comment on the two men, who were detained on Sunday.
The gunman struck on Saturday afternoon, attempting to shoot his way into 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 but a 55-year-old man was shot dead and three police officers injured. The shooter then attacked a synagogue, killing a guard outside and injuring another two police officers.
Danish media widely reported the gunman to be Omar Abdel Hamid El-Hussein. Reuters could not confirm his identity and police declined to comment.
Denmark became a target of violent Islamists 10 years ago after the publication of cartoons lampooning the Prophet Mohammad, images that led to sometimes fatal protests in the Muslim world. Many Muslims consider any representation of the Prophet blasphemous.