The students fled the scene after the attack, but recorded a 25-second video where they threatened to “put 39 more bullets into the teacher”.
Both the students, who were taking coaching classes from the victim identified as Sumit, called him outside the class and fired at him with a pistol, police added.
The teacher sustained an injury to his left leg.
The students ran away on a motorcycle after shooting the teacher, but stopped midway to record a threat video.
In the video, one of the two students can be heard saying that he wants to put a total of 40 bullets into the teacher, and 39 more bullets will follow in the next six months.
The video has gone viral on social media, raising concerns about the matter.
Deputy Commissioner of Police (DCP) West, Sonam Kumar, said that the motive behind the attack appeared to be a dispute between the students and the elder brother of the teacher, who also attends the same coaching class.
Both the accused and the victim are from Malupur village.
Meanwhile, the wounded teacher has been admitted to a hospital, and is currently under treatment.
The Khandauli police have taken cognisance of the incident.
DCP Sonam Kumar added the police have mobilised teams to arrest the accused, both underage.
Further investigation into the case is underway.