One person was injured in the armed attack at the al Noor Islamic Centre near Oslo on Saturday.
Assistant police chief Rune Skjold told a news conference that the suspect, who is described as a young white man, was carrying several guns and had previously expressed far-right and anti-immigration views online.
He said: "We're investigating this as an attempt at carrying out an act of terrorism."
Mosque director Irfan Mushtaq said the gunman wore a helmet and a uniform, adding: "The man carried two shotgun-like weapons and a pistol. He broke through a glass door and fired shots."
A 75-year-old member of the congregation suffered a minor injury to his eye as he overpowered the gunman - the only injury from the attack.
Mr Mushtaq said: "So this guy came to the door and our hero, a man of 75 years old, he was very fast in the reaction.
"He had just sat down to read the Koran, he got up and he just started moving towards this terrorist attacker, even though this terrorist attacker was shooting at the same time, and took control of him from the front."
The group were preparing for Sunday's Eid al Adha festival.
Norwegian Prime Minister said: "I think that we need to do the work that we are doing on combat(ting) hate speech.
"We have a special action plan towards that, which is not just on Islamophobia but also on a lot of other issues where you have hate speech.
"We have to work in schools to work on their empathy level, to understand each other."
The attacker, who is now in custody, is also suspected of killing one of his own family members who was found dead at his home, police said.
Earlier in the year, the centre implemented extra security measures, following the New Zealand mosque attacks in which more than 50 people lost their lives.