(CNN) -- Danish political cartoonist Kurt Westergaard hid in a "panic room" inside his home as a man wielding an ax and knife cracked the glass in the home's front door, Danish police said Saturday.
Police said a home alarm alerted them to the scene in Aarhus at 10 p.m. Friday, and they were attacked by the suspect when they responded. Police shot the suspect.
Westergaard took his 5-year-old granddaughter into the "panic room" when he realized what was happening, Chief Superintendent Ole Madsen said.
Westergaard, who has been threatened for drawing cartoons of the Prophet Muhammad, is ordinarily accompanied by bodyguards when he leaves his home, but nobody was on guard at the house Friday, the Security and Intelligence Service told CNN.
Police said Westergaard was "being taken care of" after the break-in, but wouldn't reveal his new location.
The suspect, meanwhile, appeared in court Saturday, charged with attempted assassination, the Danish Intelligence and Security Service said.
The suspect was shot in the right leg and left hand and hospitalized after the incident, police said. Video showed him appearing in court Saturday strapped onto a stretcher.
Authorities did not identify the suspect because the judge decided it would be illegal to disclose his name, said Madsen, with the East Jutland Police. Authorities said he was a 28-year-old Somali who has legal residency in Denmark and lives in Sjaelland, near Copenhagen.
The suspect was charged with the attempted assassination of Westergaard and a police officer on duty, the intelligence service said.
The judge ordered the suspect held for four weeks while the investigation proceeds.
Madsen said the man is the only suspect in the case, and he would not say whether police were investigating anyone else.
Police had no indication that an attack was being planned on Westergaard, Madsen said, though the intelligence service said the suspect had been under surveillance because of his terrorist links.
Danish intelligence officials said the suspect is connected to al-Shabaab, al Qaeda's ally in east Africa.
The incident "once again confirms the terrorist threat that is directed against Denmark and against cartoonist Kurt Westergaard, in particular," said Jakob Scharf, spokesman for the Danish Security and Intelligence Service.
Westergaard's caricature of Muhammad -- showing the prophet wearing a bomb as a turban with a lit fuse -- sparked an uproar among Muslims in early 2006 after newspapers reprinted the images months later as a matter of free speech. The cartoon was first published by the Danish newspaper Morgenavisen Jyllands-Posten in September 2005.
At the time, Westergaard said he wanted his cartoon to say that some people exploited the prophet to legitimize terrorism. However, many in the Muslim world interpreted the drawing as depicting their prophet as a terrorist.
Over the years, Danish authorities have arrested other suspects who allegedly plotted against Westergaard's life.
After three such arrests in February 2008, Westergaard issued a statement, saying, "Of course I fear for my life after the Danish Security and Intelligence Service informed me of the concrete plans of certain people to kill me. However, I have turned fear into anger and indignation. It has made me angry that a perfectly normal everyday activity which I used to do by the thousand was abused to set off such madness."
Scharf said authorities have taken measures to ensure Westergaard's safety, and that the protection has "proven effective."