Aitizaz Hasan tackled the bomber as he stood outside as a punishment for being late to school in Hangu, a town in Khyber Pakhtunkhwa, on Monday.
His two companions fled the scene after spotting the bomb being carried by the man, who was trying to gain access to the school, but Aitizaz grabbed the bomber.
Unable to stop him from detonating his bomb, Aitizaz later died of his wounds in hospital.
Hangu has a large community of Shias, an Islamic sect which many militant groups regard as heretics who should convert to the majority Sunni faith or be killed.
Aitizaz's actions are thought to have saved the lives of many of the 2,000 students who were believed to be in the building at the time.