His face and neck marked by bruises and scratches, Philip Manshaus was also charged with attempted murder, as well as the murder of his stepsister. Prosecutors are seeking to extend his custody for another four weeks. He appeared to smile at photographers before the judge opened the case behind closed doors.
Mr Manshaus is accused of opening fire at the Al-Noor Islamic Centre in Baerum, west of the capital Oslo, on Saturday.
Shortly after the attack, the body of his 17-year-old stepsister was found at a house in Baerum.
There were three people inside the centre at the time of the attack and the gunman was overpowered before police arrived. The mosque’s director said the attacker had gone into the building wearing a helmet and body armour, carrying several weapons. Several shots were fired but no-one was seriously hurt in the mosque.
A 65-year-old retired Pakistani air force officer, Mohammad Rafiq, has been praised for seizing the attacker, pinning him down and taking his weapons from him.
When the suspect appeared at Oslo district court on Monday, prosecutors sought a four-week extension to his custody with a ban on prison visits and no access to media coverage. His defence lawyer, Unni Fries, said earlier that he denied the criminal charges and was not speaking to investigators.
Police said the suspect appeared to have far-right and anti-immigrant views. Ahead of the attack, a message was posted on the EndChan forum purporting to be from Philip Manshaus. EndChan said its moderators had deleted a thread and its “primary domain” was taken offline after the shooting.
The post made a reference to New Zealand mosque attack suspect Brenton Tarrant, who is accused of murdering 51 people in Christchurch last March.
Eight years ago a Norwegian neo-Nazi murdered 77 people, first in Oslo and then at a summer youth camp run by the centre-left on the island of Utoeya. Anders Breivik was jailed for 21 years for the Utoeya massacre and later campaigned against the conditions in which he was being held.