One worshipper knocked the axe from the man’s hands, and held him down until police arrived, local media reports.
A 24-year-old man was arrested at the scene in the suburb of Mississauga, and he has since been charged.
Some congregants had minor injures from the bear spray, the mosque’s imam said.
One of the worshippers said the experience was “terrifying” and described hearing a scream before turning around to see a man holding an axe and using bear spray – similar to pepper spray – against three people.
“By the time he was spraying, the people in the first row realized something was going on and one of the young men turned around and knocked away the axe before he had a chance to use it,” Noorani Sairally told Canadian newspaper The Globe and Mail.
The young man then held the alleged assailant down until police arrived, the witness said.
“Before he could inflict harm on any worshippers, several congregants bravely were able to stop him in his tracks,” imam Ibrahim Hindy said in a statement, describing the moment the attacker entered the site.
“Our community will never be broken and we refuse to be intimated,” he added.
Police have named the man they arrested as Mohammad Moiz Omar, and charged him with six offences including assault with a weapon and administering a noxious substance with intent to endanger life or cause bodily harm.
Following initial uncertainty over a possible motive, investigators now say they believe the attack was a “hate-motivated incident.”
Prime Minister Justin Trudeau was one of a number of high-profile Canadian public figures to condemn the attack, which he described as “incredibly disturbing” and applauded the courage of the worshippers at the mosque.
Canada’s Muslim community has been targeted in a number of deadly attacks, including in 2017 when a shooting at a Quebec City mosque killed six people and left another eight wounded.
And last year, four members of the same Muslim family were killed after a vehicle hit them in London, Ontario, which was described by police as a deliberate Islamophobic attack.