The shooting at a mosque near Oslo is being treated as an "attempted act of terror", Norwegian police have said, with the suspect appearing to harbour far-right, anti-immigrant views.

"We are looking at an attempted act of terror," acting chief of the police operation Rune Skjold told a press conference.

The suspected shooter at the al-Noor Islamic Centre near the Norwegian capital - a young, white male carrying several guns - had expressed far-right, anti-immigrant views online, assistant chief of police Rune Skjold told a news conference.

"We're investigating this as an attempt at carrying out an act of terrorism," he said.

The suspect had been apprehended after the attack, in which shots were fired but no one was hurt, with members of the congregation having overpowered him before police arrived.

"These people showed great courage," the police chief said.

Only three people were present in the mosque at the time of the attack, preparing for today's celebration of the Eid-al-Adha festival, mosque spokesman Waheed Ahmed told Reuters.

The attacker was also suspected of killing one of his own family members, a young woman who was found dead at his home, police said earlier.