The Danish Security Intelligence Service (PET) said the nine were arrested early on Tuesday morning in or around Vollsmose, a poor district mainly inhabited by immigrants in Denmark's third largest city, Odense.
Two of men were later released.
Lars Findsen, the PET director, said: "We have uncovered evidence that suggests that some of the persons were in the process of preparing for a terrorist attack."
The men were held under anti-terrorism laws introduced after the September 11 attacks in the United States, suspected of plotting one or several bombings in Denmark or abroad, according to police.
Under Danish law, suspects can be held for several months while police and prosecutors investigate.
Lene Espersen, the justice minister, said in a statement: "PET has informed me that they have been watching a circle of people in the Odense area for some time."
The identities of the detainees were not revealed, but officials said they were aged between 18 and 33. Espersen said "most of those arrested were Danish citizens" of foreign origin though PET said that at least one was an ethnic Dane.
Espersen said the decision to arrest the men came after police discovered that several members of the group had collected materials to make explosives in preparation for an act of terrorism.
"PET have told me that they arrested the men now because it could be difficult to discover more precisely how far the plans had progressed."
The authorities provided no details on the target of the attacks, but said a police raid overnight had uncovered "materials" for the production of explosives.
Iraq war link
Anders Fogh Rasmussen, the prime minister, said Denmark needed to "take the terrorist threat seriously" because of its participation in the Iraq war.
Abu Bashar, an imam in the Vollsmose neighbourhood who knows three of the suspects, said the arrests did not come as a surprise, and that he believed the alleged terrorist attacks were linked to Denmark's participation in the war in Iraq.
"I'm afraid that there will be a terrorist attack in Denmark because there are Danish soldiers deployed in Iraq, and I'm afraid of what al-Qaeda may do if Denmark doesn't withdraw its troops," he told Danish news agency Ritzau.
A staunch ally of the United States, Denmark has 470 troops stationed in Basra, in southern Iraq, under British command.
Denmark, which also has troops in Afghanistan, last month charged five Muslim men under its terrorism laws.
Findsen said the arrests would not immediately affect Denmark's terrorism-risk assessment, which has been heightened for some time.
He said police had contacted a number of Muslim leaders to inform them about the situation.
Four young Muslims arrested last October were charged on August 24 and will face prosecution for trying to obtain weapons and explosives with the intent of carrying out an act of terrorism.
In February, cartoons lampooning the Prophet Muhammad published in a Danish paper sparked attacks on Danish embassies in parts of Asia, Africa and the Middle East in which more than 50 people died.