It was during breaks between marathon video game sessions in his mother’s apartment in Oslo that Anders Behring Breivik drafted his complicated and chilling plan.
He would kill indiscriminately with explosives and guns, surrender to authorities if he survived, then prove himself sane in court — all to publicize a manifesto accusing Muslims of destroying European society.
By any account, the attack went exactly as he intended. A court ruled Friday that Breivik was sane when he killed 77 people, most of them teenagers, in attacks that shook Norway to its core.
‘‘His goal was to be declared sane, so on that point he is satisfied,’’ said Breivik’s defense lawyer, Geir Lippestad.
The Oslo district court found the 33-year-old right-wing extremist guilty of terrorism and premeditated murder for the twin attacks on July 22 last year. Breivik first bombed government headquarters, killing eight people, before going on a shooting massacre on Utoya island that left 69 dead at a summer camp for young members of the governing Labor Party.
Prosecutors had asked for an insanity ruling, which Breivik rejected as an attempt to deflate his radical anti-Muslim views. He smiled with apparent satisfaction when the five-judge panel declared him sane and sentenced him to a 21-year prison sentence that can be extended for as long as he’s considered dangerous to society. Legal experts say that likely means he will be locked up for life.
‘‘He has killed 77 people, most of them youth, who were shot without mercy, face to face. The cruelty is unparalleled in Norwegian history,’’ Judge Arne Lyng said. ‘‘This means that the defendant even after serving 21 years in prison would be a very dangerous man.’’
In his final words, Breivik regretted not killing more people, apologizing to other ‘‘militant nationalists’’ for not achieving an even higher death toll. He said he wouldn’t appeal the ruling because that would ‘‘legitimize’’ a court he said got its mandate from a political system that supports multiculturalism.
Prosecutors also said they would not appeal, bringing the legal process for Norway’s worst peacetime massacre to an end and providing closure for victims’ families and survivors, who have had to endure weeks of testimony from Breivik describing the victims as traitors for embracing immigration.
‘‘I am very relieved and happy about the outcome,’’ said Tore Sinding Bekkedal, who survived the Utoya shooting. ‘‘I believe he is mad, but it is political madness and not psychiatric madness. He is a pathetic and sad little person.’’
From Europe’s far right, the reaction was mixed. Some argued that Friday’s verdict played into their core beliefs, though they have spoken out against his violent rampage.
‘‘It was obviously wrong what he did, but there was logic to all of it,’’ said Stephen Lennon, the 29-year-old leader of the English Defense League, an anti-Muslim group. ‘‘By saying that he was sane, it gives a certain credibility to what he had been saying. And that is, that Islam is a threat to Europe and to the world.’’
Frank Franz, a spokesman for the German far-right party NPD, distanced his party from Breivik.
‘‘We consider his deeds to be those of a murderer. It’s as simple as that,’’ Franz said. ‘‘For us, it had nothing to do with politics.’’
During the trial, Breivik said his massacre was meant to draw attention to a manual of far-right terrorism that he released on the Internet just before the attacks. In it, he predicted that the government would try to cast him as an ‘‘insane, inbred, pedophile Nazi loser’’ if brought before a court.
Breivik’s lawyers say he is planning to write new books from Oslo’s high-security Ila Prison, where he has been held in isolation since his arrest and where he will likely also serve his sentence. He has access to a computer there but no Internet connection. His lawyers say he has already exchanged letters with supporters, but prison staff said they can stop mail encouraging illegal acts or the creation of criminal networks.
Asked whether he thought Breivik had achieved his desired outcome, prosecutor Svein Holden said: ‘‘I don’t think Breivik’s wishes have had an impact on the court.’’
Since Breivik admitted to the attacks, his sanity was the key issue to be decided by the trial, with two psychiatric teams reaching opposite conclusions. One gave Breivik a diagnosis of paranoid schizophrenia, a severe mental illness that would preclude imprisonment. The other found him narcissistic and dissocial — having a complete disregard for others — but criminally sane.
The court criticized the psychiatric assessment that found Breivik insane, saying his perception of being a commander in a civil war can be explained in the context of a ‘‘fanatic and right-wing extremist view of the world’’ rather than as delusions of a sick mind.
It also found his controlled behavior while planning and carrying out his complex plot ‘‘difficult to reconcile with an untreated form of paranoid schizophrenia.’’
The son of a Norwegian diplomat and a nurse who divorced when he was a child, Breivik had been a law-abiding citizen until the attacks, except for a brief spell of spray-painting graffiti during his youth.
According to Breivik’s manifesto, he plotted for nearly nine years to carry out his attacks, but prosecutors said he only started planning terror after moving back with his mother in 2006. He withdrew from friends and played the video game ‘‘World of Warcraft’’ for 16 hours a day.
Breivik joined a pistol club and started acquiring weapons and explosives, legally, for his attacks. In the spring of 2011, he moved into a farm where he tested his explosives and made the final preparations for his ‘‘operation.’’
Breivik testified during the trial that he expected to be killed by police. Instead, their bungled response allowed him to hunt down panicked teenagers on Utoya for more than an hour before police arrested him.
A boat carrying a SWAT team to Utoya was overloaded and stalled, while Norway’s only police helicopter wasn’t used because its crew was on vacation.
Norway’s justice minister and police chief both resigned in the aftermath, and some critics even called on the prime minister to step down.
The court didn’t believe Breivik’s claims of belonging to a secretive network of ‘‘Justiciar Knights,’’ or ‘‘Knights Templar.’’ Investigators say it doesn’t exist.
The trial could not answer whether the network was a delusion — Breivik insisted it exists — or an attempt by him to inspire like-minded people to form such a network.
His manifesto spelled out the order’s ranks and greeting — a clenched-fist salute that he flashed at the start of Friday’s hearing. It also contained chilling advice for jailed members.
‘‘When incarcerated, the Justiciar Knight should do everything in his power to escape from prison,’’ he wrote. If successful, the ‘‘knight’’ should plot between three to five assassinations as a ‘‘bonus operation.’’