Peter Harvey denies a charge of attempted murder in July 2009
A science teacher beat a pupil around the head with a dumbbell while shouting "die, die, die", a court heard.
Peter Harvey, 50, hit the 14-year-old boy with a 3kg weight at All Saints' Roman Catholic School, Mansfield, a jury heard.
He denies attempted murder and causing grievous bodily harm (GBH) with intent, but has admitted a charge of GBH.
Nottingham Crown Court was told students were filmed calling Mr Harvey a "psycho" moments before the attack.
Another pupil was filming as Mr Harvey tried to restore discipline.
The injured schoolboy, whom Mr Harvey confronted for misbehaving in class, suffered a fractured skull and bleeding on the brain.
Stuart Rafferty QC, prosecuting, said Mr Harvey was sent home from the school in December 2008 after telling an education adviser he might harm somebody.
He returned to the classroom in April 2009.
Mr Harvey was "happy" and "positive" on the morning of the attack, the court heard.
But, after a girl with behavioural difficulties started being disruptive it was alleged he kicked her, Mr Rafferty said.
He added: "She left the classroom in a state of tears and some of the class took exception to the way she had been treated and started calling him a psycho.
"He didn't seem to respond to that and told the class to get on with their work."
'Chased round classroom'
The schoolboy victim then started waving a wooden metre rule and a metal Bunsen burner about in "high jinks" before he was attacked, the court heard.
Mr Harvey chased him round the classroom and the boy swore at him, the jury was told.
Mr Rafferty said: "That seems to have lit the blue touch paper because Mr Harvey grabbed him by his collar and started dragging him out of the classroom.
"He threw him to the ground and armed himself with a 3kg dumbbell and began to hit the boy about the head with it.
"He struck at least two blows to the head which caused serious injury, really serious injury.
"At the time the blows were being struck Mr Harvey was only heard to say one thing.
"What he was saying was 'die, die, die'."
'Felt no emotion'
The court heard that one pupil tried to drag Mr Harvey off the boy, who was lying on his back looking "frightened and confused".
The teacher was kneeling above him, raising the dumbbell to shoulder height for each of the blows.
Mr Rafferty said: "No-one can say for one moment what happened to this boy was deserved or justified.
"What he [Mr Harvey] did was grossly disproportionate to the wrong inflicted on him by the boy or other members of the class."
The court heard that Mr Harvey later told police he felt like he was watching himself on television.
He said he was not feeling any emotion and "couldn't think at all".
The jury was told one 15-year-old girl, who was in the class when the attack happened, claimed she confronted Harvey about his behaviour moments before the attack.
In an interview given to police, she said: "I said to him, 'Sir, I think you are having a mental breakdown' because people were scared of him. He started murmuring something about killing me."
Describing the attack, the girl added: "He grabbed him by the neck and forced him out into the corridor. The class ran out and he got him to the floor.
"By this time he was doing something to him. He grabbed a weight and hit him on the head constantly. He didn't stop and blood was everywhere.
"Everyone was screaming and then two people went and got teachers."
The trial continues.