A teacher in northwest Pakistan accidentally shot dead a 12-year-old pupil on Thursday while cleaning his pistol in the staff room, police said.

Teachers in northwest Pakistan were given permission to carry firearms in the classroom after Taliban militants massacred 132 students at a school in the city of Peshawar in December.

Thursday's deadly incident happened on the outskirts of Mingora, around 180 kilometres (110 miles) northeast of Peshawar.

"Majid Khan, a teacher at the private Sangota Model School was cleaning his pistol in the staff room when it fired a bullet by accident, hitting a student passing through the corridor," local police official Fazl Rabi told AFP.

He said the student died on the spot.

Saleem Khan Marwat, the area police chief, confirmed the incident and said the teacher had been arrested.

Northwestern Khyber Pakhtunkhwa province allowed teachers to carry guns -- and began giving them firearms training -- in January, saying it could not provide police guards for every school.

The move was part of efforts to beef up school security after the Peshawar massacre, the deadliest terror attack in Pakistani history.

Heavily armed militants went from room to room at an army-linked school, eventually gunning down a total of 150 people.

But teachers' associations objected to arming staff, saying it was not their job to fight off militants.