(adds details, quotes)

By Nikolaj Skydsgaard

COPENHAGEN, Dec 11 (Reuters) - Danish police arrested about 20 people on Wednesday after carrying out raids throughout the country to thwart what they suspected were preparations for an Islamist militant attack, police and security officials said.

The detainees had tried to obtain explosives and firearms, police said.

The raids were mounted on the suspicion that several people had been planning an attack, the Danish intelligence service said in a news conference with police.

"It is our assessment, that those people are driven by a militant, Islamist motive," operational chief of the intelligence service, Flemming Drejer, said.

Police did not give a precise number for the arrests.

Some of those arrested would face preliminary questioning on Thursday on charges of terrorism, chief of police Jørgen Bergen Skov said.

"It's important to underline, that we detained all those, we have been looking for," Skov said. "We now have the situation under control."

Denmark has not seen a militant attack since 2015, when two people were killed and six police officers were wounded.

In that incident, a lone gunman shot and killed a man outside a culture centre hosting a debate on freedom of speech, and later killed a person outside a Jewish synagogue in central Copenhagen. The gunman was killed in a shoot-out with police.

This year, the Danish government imposed temporary border controls at its border with Sweden following the bombing of the Danish Tax Agency in Copenhagen, which led to the arrest of three Swedish men. (Reporting by Nikolaj Skydsgaard and Andreas Mortensen; Editing by Angus MacSwan)

Our Standards: The Thomson Reuters Trust Principles.