Anders Behring Breivik has been convicted of terrorism and premeditated murder for bomb and gun attacks that killed 77 people and sentenced to a special prison term that would allow authorities to keep him locked up for as long as he is considered dangerous.
Breivik, a self-styled anti-Muslim militant, looked pleased as Judge Wenche Elisabeth Arntzen read the ruling, declaring him sane enough to be held criminally responsible for Norway's worst peacetime attacks.
Lawyers for the 33-year-old Norwegian said before the decision that Breivik would appeal any insanity ruling but accept a prison sentence.
Going against the recommendation of prosecutors, who had asked for an insanity ruling, Arntzen imposed a sentence of "preventive detention", a special prison term for criminals considered dangerous to society.
She set the minimum length of imprisonment to 10 years and the maximum at 21 years, the longest allowed under Norwegian law.
However, such sentences can be extended under Norwegian law as long as an inmate is considered dangerous.
Wearing a dark suit and sporting a thin beard, Breivik smirked as he walked in to the courtroom to hear his sentence and raised a clenched-fist salute.
Breivik, 33, confessed to the attacks during the trial, describing in gruesome detail how he detonated a car bomb at the government headquarters in Oslo and then opened fire at the annual summer camp of the governing Labour Party's youth wing.
Eight people were killed and more than 200 injured by the explosion.
Sixty-nine people, mostly teenagers, were killed in the shooting massacre on Utoya island. The youngest victim was 14.
Some who lost loved ones in the attacks welcomed the ruling.
"Now we won't hear about him for quite a while. Now we can have peace and quiet," Per Balch Soerensen, whose daughter was among those killed in the shooting massacre, told Denmark's TV2.
"He doesn't mean anything to me, he is just air."
During the trial, Breivik said that being sent to an insane asylum would be the worst thing that could happen to him and accused Norwegian authorities of trying to cast him as sick to deflate his political views.
His lawyers say Breivik is already at work writing sequels to the 1,500-page manifesto he released on the internet before the attacks.