A 13-year-old boy shot his school PE teacher in the face with an air pistol because he did not want to play rugby, Brecon Youth Court has heard.
The teacher was treated for a facial wound in hospital after the shooting.
The boy, who cannot be identified, admitted causing actual bodily harm and possessing the Beretta hand gun with intent to cause fear of violence.
He was put under an 8 month referral order, told to pay £300 compensation and told not to return to the school.
Magistrates heard the school rugby coach was targeted for allegedly "making him play rugby" despite the boy complaining about medical problems with his feet.
The teacher was tying his laces ready for a lesson when he looked up to see the boy pointing the handgun at him.
Prosecutor Karen Kirkwood said: "[He] could not believe what he was seeing.
"He heard a sound like a firecracker going off, held his chin and noticed blood on his fingers.
"He realised he had been shot, stood up and saw the boy running away."
Magistrates heard the teacher gave chase but the boy realised he was being caught and turned to point the .177 air pistol at him again.
The teacher said he was "afraid and angry but never thought he was going to die."
He ran back to his office and shut the door but the pupil followed him and waited outside with the silver gun in his hand.
Magistrates heard he raised the alarm by telephone and the school went into "lockdown".
Armed police arrived and the boy was found later near the school swimming pool.
The court heard the teacher had previously given the boy detention and lines for not attending his games classes.
The boy told police he did not like rugby or football and had a medical condition with his feet.
He said the teacher ignored him, made him play rugby and football and made him "feel bad".
The court heard firearms experts who examined the Beretta air pistol said it was not designed to kill but "was capable of doing so if misused."
Magistrates heard despite the incident the boy was not considered to be a threat to the public.
He was told the referral order meant he would need to comply with social services and sign a contract to carry out activities "to prevent him offending again."
He was also put under an order not to contact the teacher, not to enter the school nor the local stores where his teacher shops.