Peter Harvey denies a charge of attempted murder
A teacher who attacked a pupil with a dumbbell told police he thought he had killed the boy, a court heard.
Peter Harvey, 50, said he felt "really peaceful" after the attack at All Saints' Roman Catholic School, Mansfield, in July 2009.
He denies attempting to murder the boy, 14, who suffered a fractured skull.
Mr Harvey had told a colleague of his frustration at being unable to control his classes the day before the attack, Nottingham Crown Court was told.
In transcripts of a police interview, which was read out to the court, Mr Harvey said: "We went through the door into the prep room and I remember standing over him with this metal weight and I remember hitting him twice.
"Something happened and I'm sure I dropped it. I remember feeling really peaceful.
"(Education adviser Shahrukh Mugaseth) went with me to the police station and I could see my reflection in the screen.
"It was me, but it was horrible me. I wanted to destroy it but I couldn't get my hands up so I head-butted it.
"I just kept seeing the boy's head with me hitting it twice. I kept seeing it all the time and I thought I had killed him."
'Detached from reality'
Mr Harvey denies attempted murder and causing grievous bodily harm with intent, but has admitted a charge of causing grievous bodily harm.
Fellow teacher David Hopwood told the court Mr Harvey had confided to him that he was finding it difficult to keep order.
He said: "The day before the incident took place, I can remember having a conversation with him when he said he was finding it odd because, for the first time in 20 years, he was finding it difficult to keep the same order in the classroom.
"I think there were times when he expressed his frustration at the children because he was finding it difficult to control them, to get them to do what he wanted."
The school's education advisor Shahrukh Mugaseth arrived on the scene immediately after the attack.
He told the court: "He was speaking, not to anyone in particular, and he was saying 'die'. He repeated it about half a dozen times.
"It was as if he was looking from the outside into himself and seeing somebody he didn't recognise.
"He was totally detached from reality."
The court heard Mr Harvey was signed off from school with depression and stress, and had been referred to a counsellor between December 2008 and April 2009, after becoming "snappy" with pupils.
He said he had become afraid of crowds and had felt like "gouging" out the eyes of someone who was staring at him.
Mr Harvey said the counsellor had told him he was "too placid and gentle" and "needed to let it all out".
He told police: "I was told that being aggressive and having thoughts was very different from acting on them and that's why I wanted to get back as soon as they said I was safe."
Jurors have heard that the victim was regularly in trouble for disrupting lessons and classmates had filmed students calling Mr Harvey a "psycho" in the moments before the attack.
Witnesses earlier told the court Mr Harvey dragged the boy out of the room and carried out the attack "as if possessed".
The trial continues.