(CNN) -- At least one of three men charged with planning a terrorist attack against a Danish newspaper had previous links with terrorist suspects, according to a Swedish counter-terrorism source.
The men were remanded into custody after appearing in court in Copenhagen, Denmark, on Thursday. The court said the men must remain in custody for four weeks, with the first two to be spent in isolation.
A fourth man, a 26-year-old Iraqi national, was released Thursday. He is suspected of arranging housing for the other three men, all of whom were arrested Wednesday, the intelligence service said.
The Danish newspaper allegedly targeted, Jyllands-Posten, published cartoons of the Prophet Mohammed in 2005 and has long been a target of Islamic extremists.
"Our assessment is that their plan was to try to get access to the Jyllands-Posten building and carry out a Mumbai-style attack," the head of Denmark's intelligence service, Jakob Scharf, said Wednesday. He described the suspects as militant Islamists.
Pakistani terrorists launched gun attacks on hotels and other targets in the Indian city of Mumbai, India, in 2008, killing more than 170 people.
Denmark's Justice Minister Lars Barfoed said the plot constituted "probably the most serious terror attempt in Denmark so far."
Defendant Munir Awad, a 29-year-old Swedish citizen born in Lebanon, was in a group of Swedish militants that traveled to Pakistan in 2009, where he was arrested and deported, according to a Swedish counter-terrorism source,
The group allegedly planned to travel to North Waziristan, a tribal agency that has been a longstanding safe haven for al Qaeda. Pakistani authorities believe they planned to meet with terrorist operatives there.
One of Awad's traveling companions was Mehdi Muhammad Ghezali, a former inmate at Guantanamo, the Swedish counter-terrorism source said. Ghezali was a close associate of a man who met American David Headley in Sweden in 2009, the source said. Headley was planning his own attack on the Danish newspaper, the source said.
Ghezali is living freely in Sweden. He does not face charges, the source said.
Headley's contact in Sweden -- known only as "Farid"- was of Moroccan origin, according to an interview of Headley by India's National Investigation Agency that was obtained by CNN. He was an associate of senior al Qaeda commander Ilyas Kashmiri, whom Headley met in Pakistan and under whose orders he was operating.
Kashmiri, a Pakistani terrorist operative, has emerged as one of al Qaeda's most dangerous operational masterminds in the last year. Western counter-terrorism officials believe he was behind a Mumbai-style plot against the United Kingdom, Germany and France, which led to a U.S. State Department travel advisory for Europe in October.
Kashmiri personally instructed Headley to meet with Farid, the Swedish counter-terrorism source said. BUt according to Headley's account, Farid was not able to assist him.
"Farid told me he was being continuously watched and he was not available for Denmark project," Headley is quoted as telling Indian investigators.
After the meeting, Headley traveled to Denmark and was arrested in Chicago in October 2009 as he was about to leave for Pakistan. He later confessed to planning the November 2008 Mumbai attacks and to carrying out a reconnaissance of the newspaper offices with the intent of launching a terror attack. Video of the offices was found in his luggage.
Farid, a Swedish citizen, is still suspected of being at the center of militant activity in Stockholm, and is currently under observation, Swedish counter-terrorism sources told CNN.
Munir Awad, for his part, has long been on the radar screen of Swedish counter-terrorism services.
Awad is suspected of having joined up with jihadist militants in Somalia in 2006, before fleeing the country after Ethiopian troops launched a military operation against Islamist militant fighters there, according to Danish counter-terrorism expert Michael Taarnby.
Awad returned to Sweden after he and several other Swedish militants fleeing Somalia were arrested in Kenya in January 2007.
According to Danish media, Awad and two Swedish associates arrested in Denmark denied the charges against them in court Thursday. They were being held in custody.
According to Swedish media reports a fifth man arrested in Sweden, Wednesday -- identified as Sahbi Zalouti, a 37-year-old Swedish citizen of Tunisian descent -- also traveled to Pakistan in 2009 via Turkey and Iran.
Zalouti appeared in a court north of Stockholm Thursday and was ordered detained on probable cause for suspicions that he was preparing terror crimes. In court his lawyer said his client denied the accusations.
In August 2009, Zalouti was arrested by Pakistani security services in Balochistan, a western province of Pakistan and deported for having ilegally entered the country, according an account in the Swedish Aftonbladet newspaper, which interviewed him after his return. In that interview Zalouti spoke of traveling with other Swedish militants to Pakistan.
CNN Wednesday located a Facebook account in Zalouti's name. The picture on the account appeared to be a jihadist warrior whose sword was dripping with what looked like blood.
The Swedish arrests were the second high profile terrorism case linked to the country this month, after a Swedish national of Iraqi descent blew himself up in a suicide bombing attack in Stockholm in which he was the only victim.
"It's a sharp wake up call to Sweden that it needs to grapple with the problem of Islamist extremism within its borders; previously many Swedes thought the country immune," Magnus Ranstorp, a terrorism expert at the Swedish National Defence College, told CNN.
The men had been under surveillance for months, and were among 200 radicals identified in a recent Swedish intelligence report, according to intelligence sources in Scandinavia. Sweden raised its terror alert in October. An estimated 300,000 Muslims live in Sweden.
Denmark's intelligence service said the men had rented a car near Stockholm and driven to Denmark with a submachine gun, silencer and ammunition, with the intent of carrying out an attack by the New Year. Swedish authorities say the car was followed by security police, who knew there were weapons in the car.
There have been several plots against the newspaper building. Earlier this year, a Belgian of Chechen descent was injured in Copenhagen when a bomb he was carrying blew up in a nearby hotel. He is awaiting trial.
According to Danish terrorism expert, Michael Taarnby, it's unclear whether Islamic radicalization is growing in Denmark and Sweden, but he said extremists appear more prepared to use violence.
Intelligence analysts point out that the men alleged to have been involved in this latest plot are between ages 26 and 43, and are not the alienated youth often associated with such plots.