Tom slips out secretly on the night before the start of Muff Potter’s trial. Potter has been framed for the murder of Dr Robinson by the villainous Injun Joe, who committed the murder himself, and there is no real hope for Potter; the trial seems destined to be more or less a formality, with the verdict and sentence already decided.
Tom and Huck became inadvertent witnesses to the murder and they are the only people, besides Injun Joe, to know the truth of the matter. However, their deadly fear of the violent Injun Joe prevents them at first from revealing the truth to the authorities, and indeed they swear the most solemn oath never to tell.
As the trial draws nearer, however, the two boys feel increasingly guilty over their terrible secret, and wait to see if Muff Potter will be released without their having to do anything. But this hope is in vain:
But nothing happened; there seemed to be no angels or fairies interested in this luckless captive.(chapter 24)
Therefore Tom realises that Potter’s life depends entirely on the testimony that he and Huck are withholding. Huck remains too scared to do anything but Tom, on the eve of the trial, decides to take action. When he slips out that night, it is to go and see Potter’s lawyer and reveal his crucial evidence. We only realise what he has done at the trial itself, when he appears as a witness for the defence, leading to Potter’s acquittal and Injun Joe absconding.
This incident shows that Tom is quite courageous and has a sense of fair play, although it is true that he continues to live in fear, having continual nightmares in which the bogeyman figure of Injun Joe returns to wreak his revenge:
..his nights were seasons of horror. Injun Joe infested all his dreams, and always with doom in his eye. (chapter 25)
Fortunately for Tom, Injun Joe never does catch up with him – although he surfaces unexpectedly in the caves where Tom and Becky are for a while trapped. But they escape, and he starves to death in the caves, finally becoming an object of pity as well as fear.