Five Islamic extremists have been caught as they planned to massacre staff at the Danish newspaper that printed cartoons of the Prophet Mohammed.
The men, arrested in a security service operation, intended to shoot as many people as possible at the Jyllands-Posten daily in Copenhagen, according to Danish officials.
Denmark's intelligence service held four men in two raids in suburbs of the capital and seized an automatic weapon, a silencer and ammunition.
Swedish police said they arrested a 37-year-old Swede of Tunisian origin living in Stockholm.
"An imminent terror attack has been foiled," said Jakob Scharf, head of the Danish security and intelligence service, known as PET. He described some of the suspects as "militant Islamists with relations to international terror networks" and said that more arrests are possible.
PET said it seized a 44-year-old Tunisian, a 29-year-old Lebanese-born man and a 30-year-old who were living in Sweden and had entered Denmark late on Tuesday or early on Wednesday. The fourth person detained was a 26-year-old Iraqi asylum-seeker living in Copenhagen.
The four men face preliminary charges of attempting to carry out an act of terrorism. They will face a custody hearing on Thursday.
Zubair Butt Hussain, a spokesman for the Muslim Council of Denmark, called the plan "extremely worrying". He added that the organisation "absolutely condemns any act of terrorism regardless of the motives and motivations that may lie behind".
There have been at least four plots to attack against Jyllands-Posten or Kurt Westergaard, the artist who drew the most contentious of 12 cartoons, which were published by the daily in 2005 as a challenge to perceived self-censorship.
"The foiled plot is a direct attack on democracy and freedom of press," Mr Westergaard said. "We may not and won't let anyone forbid us to criticise radical Islamism. We may not be intimidated when it comes to our values."