The 28-year-old Somali national armed with an axe and a knife had terrorist intent and was close to the Somali Shebab movement and al-Qaeda, which was responsible for the 9/11 attacks in the United States, the internal security service PET said in a statement.
Danish police shot and wounded the man who tried to enter Westergarrd’s home.
He was shot in a knee and a hand but his life was not in danger, according to reports. He was expected to be charged with attempted murder of Westergaard and a police officer. It is understood the Somali man had a legal permit to be in Denmark.
Kurt Westergaard, who has received several death threats since a Danish newspaper four years ago published his drawing featuring Prophet Mohammed wearing a turban in the shape of a bomb, was at home in Viby near the western city of Aarhus guarded by police when the intruder tried to get in.
Prosecutors said a Chicago-based men spent at least a year working with a Pakistan-based terrorist group to plan an attack.
The security alarm was set off when the man tried to enter the house before being shot by the guards, the daily Politiken reported online. The intruder, wounded in the arm and leg, was hospitalised.
It is unclear whether the Somali man managed to enter the home.
“I locked myself in our safe room. He tried to smash the entrance door with an axe,'' Westergaard, 74, who was in the house with a five-year-old grandson, told Danish news agency Ritzau.
PET said in a statement: “The attempted murder of cartoonist Kurt Westergaard is linked to terrorism. The person arrested ... has close links with the Somali terrorist organisation al-Shebab as well as with the heads of al-Qaeda in east Africa.
“He is also suspected of being implicated in terrorist activities when he was in east Africa. The individual arrested has also been a member of a terrorist network implanted in Denmark that has been under surveillance by PET for a long time.''
Police had earlier reported there were three intruders before saying there was just one.
Ritzau said a dozen police vehicles were at the scene while sappers were sent in to look for a bomb that might have been laid.
Westergaard is one of 12 cartoonists whose drawings of the Muslim prophet were first published in Danish newspaper Jyllands-Posten in September 2005, sparking controversy among Muslims worldwide.
The 12 cartoons were considered offensive by many Muslims and their publication sparked violent protests worldwide in January and February 2006.
Two men had already been arrested in 2006 for plotting Westergaard's murder.
Demonstrators burned Danish flags in protests that culminated in February 2006 with the torching of Danish diplomatic offices in Damascus and Beirut and dozens of deaths in Nigeria, Libya and Pakistan.