A worshipper says he confronted the gunman and threw a credit card reader at him.
Two police officers, one of them armed with only a handgun, chased and arrested Brenton Tarrant, 28.
The suspect had explosives in his car and was planning more attacks that day, said Prime Minister Jacinda Ardern.
She has called the killings “an act of terror”. Later on Monday, her cabinet is to discuss changing the country’s gun laws.
Investigators have been examining the bodies, which are due be returned to relatives for burial by Wednesday.
Tributes have been paid for the victims while some 34 people remain in hospital, including a four-year-old girl who is in a critical condition.
Afghan-born Abdul Aziz, 48, said he was inside the Linwood mosque, the second target of the attacker, when he heard shouts that someone had opened fire.
When he realised the mosque was being attacked, he picked up a credit card machine and ran towards the attacker. He threw the device at the gunman when he returned to his car to pick up another weapon, and ducked between cars as the gunman opened fire on him.
Mr Aziz, who was in the mosque with four of his children, picked up a gun that the suspect had dropped and pulled the trigger, but it was empty. He followed the attacker back inside the mosque, where he eventually confronted him again.
“When he saw me with the shotgun, he dropped the gun and ran away toward his car. I chased him,” he told Reuters news agency. “He sat in his car and… I threw [the gun] through his window like an arrow. He just swore at me and took off.”
Linwood’s acting imam Latef Alabi told the Associated Press the death toll would have been far higher at the mosque if Mr Aziz, who said he had not feared the gunman, had not acted.
Two rural community police officers who were nearby chased the attacker, blocked his car and captured him. The moment was filmed by a witness, who posted the footage on social media.
“[The officers] put New Zealand first,” Ms Ardern said on Saturday, adding that they would be recognised for their bravery.