The killer, who cannot be named for legal reasons, pleaded guilty to the culpable homicide of Euan Craig, 14, at the High Court in Glasgow last month.
And at a hearing today at the High Court in Edinburgh he was sent to a Young Offenders' Institution.
The teenager was 14 when he punched Euan five times on the side of his head. The boy later died of his injuries.
Judge Lord Bracadale. told the killer he had no other option but to impose a custodial sentence. Lord Bracadale added: "There is no sentence that can be imposed upon you today that can bring back Euan or can compensate the Craig family for their loss.
"You were 14 when you committed this culpable homicide. I have come to the view that the sustained nature of the assault, the circumstances in which it was committed and the devastating consequences which flowed from it, combine to indicate that, despite your age, the only appropriate disposal is a custodial one."
The earlier hearing was told he had repeatedly punched fellow third-year pupil Euan at the school in Glasgow's South Side in May after being accidentally hit by a spongeball.
Prosecutor John Scullion said despite Euan apologising for the accident he was punched five times on the side of his head.
Euan then went to sit beside other pupils before suddenly slumping from the bench as he started to suffer a seizure.
A teacher rushed to help, but Euan did not respond. He was rushed to the Southern General Hospital where a CT scan revealed he had extensive bleeding on the brain.
Euan never recovered and was pronounced dead the next afternoon.