OSLO - Anders Behring Breivik, the man who killed 77 people in a bomb attack and gun rampage in July 2011, was sentenced to 21 years in prison, reports CNN.

The five judges at Oslo district court were unanimous in ruling that Breivik was sane, and convicted the 33-year-old far-right extremist of terrorism and premeditated murder, reports the BBC.

The 21-year prison sentence is the maximum allowed by Norwegian law, however the  sentence can be prolonged at a later date if the court judges that he remains "a danger to society", notes CNN.

According to the Norway Post, Breivik has stated that if he was declared sane by the court, he would not appeal the sentence. 

Breivik had hoped to be found sane by prosecutors to avoid what he called the "humiliation" of being dismissed as a madman, reports The Guardian.

Breivik has refused to plead guilty and has sought to justify his attacks by saying that they were necessary to stop the "Islamisation" of Norway.

Eight people died in the bombing in the capital, which was followed by Breivik's fatally shooting of another 69 people – 34 of them aged between 14 and 17 – during an hourlong systematic massacre at Utoya Island on 22 July 2011.