(CNN) -- A Somali man believed to have ties to terrorist groups was shot as he allegedly tried to enter the home of Danish political cartoonist Kurt Westergaard -- known for his controversial depictions of the Muslim prophet Mohammed -- on Friday, police said.

The 27-year-old man, who was not identified, wielded an ax and a knife and cracked a window at Westergaard's home in Aarhus, said police spokesman Morten Jensen. A home alarm alerted police to the scene at 10 p.m., and they were attacked by the man, he said.

The officers shot the man in the right leg and left hand. He was hospitalized, but was not seriously injured, police said.

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, in a statement.

Westergaard's caricature of Mohammed -- which depicted 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 terror. 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 were made 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."