Douglas Hoagland said Brandon McInerney wasn't aware of what he was doing when he shot Larry King in the back of the head at E.O. Green Middle School in Oxnard.
"He acted without thinking," Hoagland told jurors.
Prosecutors tried to discredit Hoagland's testimony, pointing out McInerney told a friend he wanted to kill King the day before the 2008 shooting.
McInerney, who was 14 at the time, is being tried as an adult on first-degree murder and hate crime charges.
Defense attorneys don't dispute their client was the shooter but say McInerney was the product of a violent upbringing and he was unable to harness his anger toward King when he made unwanted sexual advances.
The Associated Press contributed to this report.