Pakistani policemen stand beside blood on the floor at Bacha Khan University in Charsadda, near Peshawar, after an attack on the school Wednesday. At least 20 people died in the assault, which was claimed by a hard-line faction of the Taliban. (Aamir Quereshi/AFP/Getty Images)

After terrorists killed about 150 people at a school in northwestern Pakistan 13 months ago, officials started arming teachers and gave them weapons training.

Like the debate over guns in schools in the United States and elsewhere, the move was controversial and divided parents and academic officials. But a Pakistani teacher armed with a pistol is being credited with saving lives during a terrorist attack Wednesday at Bacha Khan University in Khyber Pakhtunkhwa province.

According to Agence France-Presse, Syed Hamid Husain, an assistant chemistry professor, pulled out his pistol and began firing at two of the attackers as they neared a classroom. But the 27-year-old teacher was outgunned by the militants, who were armed with assault rifles. After a gun battle, Husain was killed, students said.

Still, students at the college in Charsadda, about 30 miles from Peshawar, say Husain is hero. By pulling out his weapon, they told reporters, their teacher gave them time to escape.

“I saw a bullet hit him,” a student told AFP. “I saw two militants were firing. I ran inside and then managed to flee by jumping over the back wall.”

In an interview with The Washington Post, another student confirmed that Husain took out his pistol as the attack unfolded.

Shaid Malik, 22, a geology student, said he and some friends rushed out of their room when they heard gunfire.

“We saw the professor standing there with a gun in his hand,” he said. “He told us to rush back to our rooms and do not open the door for anyone.

“When the firing stopped, after a while, we came down and saw the professor dead, lying on the ground with the same gun in his hand.”

Another student, Mohammad Shabeer, said Husain held off the attackers for 15 minutes before he was killed.

Shabeer said another student -- who also was armed because of threats that had been made against him and his family -- helped Husain battle the attackers. That student also was killed, he said.

A group of gunmen stormed a university in northwestern Pakistan on Jan. 20 and killed at least 20 people, police said. Local media are on the scene outside Bacha Khan University. (Reuters)

“Nobody in this world could define what kind of bravery that was,” Shabeer said. “In my mind, that teacher and student emerged as the true winners of this battle.”

A spokesman for the Pakistani military was not able to confirm the students’ version of events. But one school official said the presence of armed security guards on campus had been instrumental in averting a far deadlier tragedy.

The guards battled the attackers before police and paramilitary forces arrived, which kept the gunmen from entering the women’s dormitory, the official said.

Last year, after the attack on the army-run school in Peshawar, provincial officials began voluntary training courses for teachers who wanted to bring firearms into the classroom.

With more than 35,000 schools in the province, officials told AFP at the time that they simply didn’t have enough resources to protect all of them. Some Pakistani provinces have also begun offering firearms training to primary school students, even though they are still prohibited from carrying a gun to school.

But images of nervous teachers clutching pistols or assault rifles during a training exercise caused an uproar on social media. One popular Twitter meme showed a photograph of a teacher wearing a burqa and holding a pistol.

“Do you feel safer?" it asked.

Some education leaders also protested the move, fearing guns in the classroom would put students in even more danger.

“Our job is teaching, not carrying a gun,” Malik Khalid Khan, the head of the provincial teachers association, told NBC News in January.

In June, concerns about Pakistan’s rush to armed teachers were magnified when a teacher in the country’s western Swat Valley accidentally shot and killed a fifth-grader.

The teacher had apparently been cleaning his weapon when it discharged, striking the 12-year-old as he was fetching a drink from a water cooler.

Aamir Iqbal and Haq Nawaz Khan in Charsadda, Pakistan, contributed to this report.