The 29-year-old Somali, who broke into the home of cartoonist Kurt Westergaard with an axe on New Year’s Day last year, was also convicted of attempted manslaughter, a police official said.
The court referred to the attack as an act of terrorism.
Westergaard drew a cartoon of the Mohammad, considered to be the foremost prophet by Muslims, wearing a turban shaped as a bomb with a burning fuse.
It was one of 12 cartoons of Mohammad published by Danish newspaper Jyllands-Posten.
The newspaper urged cartoonists to send in drawings of the prophet after an author complained that nobody dared to illustrate his book on Mohammed. Twelve illustrators heeded the newspaper’s call and sent in cartoons of the prophet, which were published in the newspaper last month.
Jyllands-Posten has called the cartoons a test of whether fear of Islamic retribution has begun to limit the freedom of expression in Denmark.
The publication enraged Muslims around the world.
Westergaard was also targeted for attach by Muslims in February, 2008.