A Somali man wielding an ax and a knife was shot by police as he attempted to kill an artist who drew a cartoon depicting the Prophet Muhammad that sparked outrage in the Muslim world, the head of Denmark's intelligence agency said Saturday. Jakob Scharf said in a statement that a 28-year-old man with ties to al-Qaida attempted to enter Kurt Westergaard's home in Aarhus shortly after 10 p.m. (2100 GMT) on Friday. But Westergaard pressed an alarm and police arrived minutes later, foiling the attempt on his life. The attack on the artist, whose rendering was among 12 that led to the torching of Danish diplomatic offices in predominantly Muslim countries in 2006, was "terror related," Scharf said. Westergaard, whose 5-year-old granddaughter was in the home on a sleepover, sought shelter in a specially made safe room when the suspect broke a window of the home, said Preben Nielsen of the Aarhus police. Officers arrived two minutes later and tried to arrest the assailant, who wielded an ax at a police officer. The officer then shot the man in a knee and a hand, authorities said. Nielsen said despite his injuries the suspect's life was not in danger. The suspect's name was not released in line with Danish privacy rules. "The arrested man has according to PET's information close relations to the Somali terrorist group, al-Shabaab, and al-Qaida leaders in eastern Africa," Scharf said. The PET is Denmark's intelligence agency. Scharf said without elaborating that the man is suspected of having been involved in terror related activities in east Africa. He had been under PET's surveillance but not in connection with Westergaard, he said The man, who had a staying permit in Denmark, was to be charged Saturday with attempted murder for trying to kill Westergaard and a police officer, Scharf said. It was unclear whether the suspect managed to actually get inside the home of the 75-year-old cartoonist in Denmark's second largest city, 124 miles (200 kilometers) northwest of Copenhagen. Westergaard could not be reached for comment. However, he told his employer, the Jyllands-Posten daily, that the assailant shouted "revenge" and "blood" as he tried to enter the bathroom where Westergaard and the child had sought shelter. "My grandchild did fine," Westergaard said, according to the newspaper's Web edition. "It was scary. It was close. Really close. But we did it." Westergaard was "quite shocked" but was not injured, Nielsen said. Westergaard remains a potential target for extremists nearly five years after he drew a caricature of the Prophet Muhammad wearing a bomb-shaped turban. The drawing was printed along with 11 others in Jyllands-Posten in 2005. The drawings triggered an uproar a few months later when Danish and other Western embassies in several Muslim countries were torched by angry protesters who felt the cartoons had profoundly insulted Islam. Islamic law generally opposes any depiction of the prophet, even favorable, for fear it could lead to idolatry. Westergaard, whose provocative cartoon thrust Denmark into the midst of an international crisis, has been exposed to death threats and an alleged assassination plot. The case "again confirms the terror threat that is directed at Denmark and against the cartoonist Kurt Westergaard in particular," Scharf said. In October, terror charges were brought against two Chicago men whose initial plan called for attacks on Jyllands-Posten's offices. The plan was later changed to just killing the paper's former cultural editor and Westergaard. In 2008, Danish police arrested two Tunisian men suspected of plotting to murder Westergaard. Neither suspect was prosecuted. One of them was deported and the other was released Monday after an immigration board rejected PET's efforts to expel him from Denmark. Throughout the crisis, then-Prime Minister Anders Fogh Rasmussen distanced himself from the cartoons but resisted calls to apologize for them, citing freedom of speech and saying his government could not be held responsible for the actions of Denmark's press.