Oslo, Norway (CNN) -- Anders Behring Breivik, the man who killed 77 people in a bomb attack and gun rampage just over a year ago, was judged to be sane Friday by a Norwegian court, as he was sentenced to 21 years in prison.
Breivik was charged with voluntary homicide and committing acts of terror over the attacks in Oslo and Utoya Island on July 22, 2011.
The issue of Breivik's sanity, on which mental health experts have given conflicting opinions, was central to the court's ruling.
Breivik, who boasts of being an ultranationalist who killed his victims to fight multiculturalism in Norway, wanted to be ruled sane so that his actions weren't dismissed as those of a madman.
He says he acted out of "necessity" to prevent the "Islamization" of his country.
But prosecutors had asked that Breivik, 33, be acquitted on the grounds of insanity, in which case he would have been held in a secure mental health unit.
The unanimous verdict was delivered at Oslo district court by a panel of five judges.
Breivik, dressed in a dark suit and tie, had a slight smile on his face as the decision was given.
He was sentenced to the maximum possible term of 21 years and was ordered to serve a minimum of 10 years in prison. The time he has already spent in prison counts toward the term.
The sentence could be extended in the future if he is considered still to pose a threat to society.
Reading the court's verdict, Judge Wenche Elizabeth Arntzen spoke of Breivik's own "manifesto," a document published online in which he set out his ultranationalist political views.
Breivik claimed to belong to a far-right group called the Knights Templar but the court found no evidence of its existence, the judge said.
He described his actions as a preemptive attack in defense of ethnic Norwegian people and culture, the court heard.
Breivik trained for his attack by working out in the gym, running with a backpack filled with rocks and practicing at a shooting club, the court heard.
He was under the influence of ephedrine, a stimulant, at the time of the attacks, and the possibility that this contributed to his behavior cannot be ruled out, Judge Arne Lyng said.
He used meditation techniques to cut off his emotions, Lyng said.
In the course of the 10-week trial, which wrapped up in June, the court heard chilling evidence from some of those who survived Breivik's shooting spree on Utoya Island, in which 69 people died -- most of them teenagers attending a Labour Party summer youth camp.
Inside the Norway terror suspect's mind
In his own testimony, given without any display of emotion, Breivik recounted firing more bullets into teenagers who were injured and couldn't escape, killing those who tried to "play dead" and driving others into the sea to drown.
Alleged mass killer shows no remorse
Prosecution concerned with Breivik sanity
His fertilizer bomb attack against government buildings in Oslo also killed eight people and injured many more.
It was only luck that more people were not killed and hurt in the blast, the court heard.
Breivik blamed the Labour Party in particular for promoting multiculturalism in Norway.
He has been held in Ila Prison since his detention after the killings.
Defense lawyer Geir Lippestad has previously said it is important to Breivik that people see him as sane so they don't dismiss his views.
During his trial, Breivik promised that he would not appeal if the court found him criminally responsible for his actions.
Breivik's rampage, the worst atrocity on Norwegian soil since World War II, prompted much soul-searching.
Norwegians reasserted their commitment to multiculturalism and tolerance at a series of mass public tributes held in the immediate aftermath of the massacre.
And earlier this month, Norway's chief of police stepped down after an independent commission detailed a catalog of police and intelligence failures.
It concluded that those errors cost police 30 minutes in getting to Utoya, and that dozens of lives might have been saved.
Speaking last month on the anniversary of the killings, Prime Minister Jens Stoltenberg urged Norwegians to "honor the dead by celebrating life," and said Breivik had failed in his attempt to change Norway's values.