OSLO - The trial of the worst mass murderer in Norway's peacetime history ended on Friday with Anders Behring Breivik saying that his bombing and shooting rampage was necessary to defend the country - prompting a walk-out by relatives of his victims.

A total of 77 people were killed in the single day of violence last July 22, which Breivik said was a strike against Norway's increasingly multi-cultural society.

Final arguments in the 10-week trial revolved around the question of whether the self-proclaimed anti-Muslim militant was a lunatic or not.

His defense lawyer said in closing arguments that Breivik was sane and had the right to be punished for what he believed was a political act.

The prosecution had argued on Thursday that Breivik was insane. If the judges agree, he will be destined for a mental institution instead of a prison.

"I think we all can agree that on July 22, a barbaric thing happened," Breivik said in a rambling closing statement.

"I remember that on July 21, I thought after many years of planning, that tomorrow I will die...and what is it I will die for?"

Breivik had confessed to the killing rampage in which he first detonated a bomb outside government headquarters in Oslo which killed eight bystanders, then systematically gunned down 69 people, many of them teenagers, at a summer camp run by the ruling Labour Party on the island of Utoeya.

He did not, however, accept the charges of terrorism and murder, saying that the attacks were on "traitors" whose leftist views and soft policy on immigration had damaged the country and that he was acting to defend the Norwegian people.

The killings stunned the small, prosperous and usually peaceful Scandinavian country and his trial also proved traumatic as Breivik coldly recounted the manner in which he had picked off his victims and spouted his extreme right-wing and racist views.

Survivors also gave harrowing accounts of their ordeal.

In his closing statement on Friday, a pale and tired-looking Breivik again tried to justify his actions and hit out at what he saw as the ills of modern Norway.

"My brothers in the Norwegian and European resistance are sitting out there following this trial, while planning new attacks. They could be responsible for as many as 40,000 being killed," Breivik said.

He also ranted against multiculturalism and drew mocking laughter when he said that having non-ethnic Norwegians representing the country in the recent Eurovision Song Contest was a sign of its "self-hatred".

As Breivik prepared to begin his last statement, a number of people walked out of the courtroom.

"We have no need to hear more about what he has to say," Trond Henry Blattman, leader of a victim's support group, told broadcaster TV2.

"We have heard him many times, we don't hear anything new... we want to show that we don't care about what he has to say, who he is, what he has done."

Prison or mental institution?

The court has also to weigh up conflicting psychiatric reports on the state of Breivik's mental health. A first report said his acts were inspired by fantasies of violence while the second said they were motivated by extreme right-wing zeal.

Defense counsel Geir Lippestad said on Friday that Breivik wanted to be ruled sane and punished for his actions.

"If we...take into account that the defendant has a political project, to see his actions as an expression of illness is to take away a basic human right, the right to take responsibility for one's own actions," Lippestad said.

The prosecution said on Thursday he was insane and should be committed to a mental institution.

There was also emotion in court as the trial neared its end.

Kristi Sofie Lovlie, who lost her daughter Hanne in the explosion in the government building, gave testimony on her feelings during the past 11 months of mourning.

Her courage drew applause and moved many to tears, including judges.

"I made a decision. I shall not be afraid of that man. It cannot be dangerous for me to come here. I had to come here for Hanne's sake," Lovlie said.

"Now, here we are at the end of the road. I am sure that the court will provide us with a just verdict."