It's the hapless Muff Potter who ends up being thrown in jail, where he awaits trial for the murder of Dr. Robinson. One spooky night in the cemetery, Dr. Robinson was out robbing graves with old Muff and Injun Joe. The three men got into an argument, during which Muff was knocked unconscious and Dr. Robinson was stabbed to death by Injun Joe. When Muff came to, Injun Joe was long gone, and so Muff inevitably the only suspect in the doctor's murder.
The murder and its aftermath were witnessed by Tom and Huck. But they're so scared of Injun Joe that they do not dare to let anyone know what happened on that terrible night. However, they eventually realize that if they don't come forward and tell the truth, poor old Muff's almost certain to be hanged as a murderer. So, during Muff's trial Tom and Huck bravely testify that it was Injun Joe, not Muff, who killed Dr. Robinson. All of a sudden, Injun Joe dives through the courtroom window and makes an escape. Muff has been saved from the gallows, and it's all thanks to the bravery of Tom and Huck.