Mr Justice Turner described Martyn's serious disciplinary record stretching back for months before his expulsion and said he had been 'living on borrowed time'.
The judge agreed that the April Fool's Day incident was not by itself serious enough to justify Martyn's expulsion from Birches Head High School in April last year. But he said the school's headmaster - and the appeal committee which later upheld his decision - had been entitled to take into account his history of misbehaviour.
The court heard earlier that he had been temporarily excluded from the school five times in the 13 months before he was finally permanently expelled. The headmaster could not be expected to ignore Martyn's history 'including the fact that Martyn was at the time, and to his knowledge, on borrowed time in the sense that he had been warned what was likely to happen if he again misbehaved'.
Mr Justice Turner said it would be 'tedious' and unnecessary for him to 'trawl through the misbehaviour log of this particular boy'. But the school's headmaster had told the appeals committee of Martyn's '100 detentions'.
The judge added: 'Among the incidents logged were those of 10 May 1994 when an eight year-old boy was assaulted.
'On 17 May that year he was on daily report for one to two weeks; on 18 July 1995 he was disciplined for spitting at other pupils; on 1 March 1996 there was an incident which appears on the log as a pre-meditated attack on a younger boy causing actual bodily harm'.
He said 'common sense' suggested that if a pupil misbehaved frequently and was 'repeatedly disciplined', the need to uphold the school's disciplinary credibility might demand the 'ultimate sanction'.
He added: 'There is nothing in my judgement to indicate that the committee's decision and reasoning was in any respect flawed. It follows in these circumstances that the motion must be dismissed.'
'It is also to be born in mind that Martyn had for some weeks been made fully alive to what the consequences were likely to be were he to be guilty of what I would term significant misbehaviour again.
'In my judgement it would be quite wrong simply to look at the instant case of misbehaviour and ask oneself the question: Does that justify the ultimate sanction of exclusion?' Martyn's mother Carol had her judicial review challenge to the appeal committee's decision dismissed.
Mr Justice Turner dismissed the mother's judicial review challenge and ordered her to pay the action's legal costs. As she was legally aided the costsorder is very unlikely to be enforced against her.