Jon Whitcroft lives in England with his mother and two sisters. He is 11; his father died when Jon was 4. His mother is in a relationship with a dentist, with whom Jon doesn't get along. Jon calls him "The Beard."
Jon had been the man of the house since his father died, so now he is jealous of The Beard and the time his mother spends with him. Jon plays mean pranks on The Beard, such as mixing itching powder in his mouthwash in an unsuccessful attempt to get rid of him. But instead of getting rid of The Beard, his mother sends Jon to his father's old boarding school in Salisbury — a town more than 1,000 years old and known for its cathedral. Jon feels as if he's been banished, and he cries on the hourlong train ride to his new school. He ends up having to share a room with two other boys, Angus and Stu, who do their best to pull Jon out of his miserable, homesick state.
About a week after his arrival, Jon hears horses in the night. He looks out the window and sees three pale, see-through riders, who turn out to be ghosts. One of the ghosts points a threatening finger at Jon. Stu looks, too, but he doesn't see anything. Jon decides he is either going crazy or hasn't eaten enough food that day. He peeps over the windowsill a few more times, but no longer sees the ghosts. He returns to bed and finally manages to sleep.
As it's nearing dark at the end of the next school day, Jon sees the ghosts again, but this time there are four. Although other students are with him, he is the only one who sees them. He flees in terror as the four ghostly horsemen chase after him, calling him Hartgill. Hartgill was his mother's maiden name, and Jon is puzzled over how they know his family name and why they are after him. Eventually, Jon falls down and lands on wet grass and sobs from fear. No one believes him when he tells about the ghosts who want to kill him.
To avoid becoming the joke of the school, Jon decides to tell everyone he made up the ghost story to fool a teacher, and he nearly becomes a hero rather than an object of concern. Yet he still fears the next time the ghosts will materialize, and he can barely eat lunch. Suddenly a girl sits down across from him. Her name is Ella Littlejohn, and she is sure his ghost story is factual. Jon learns that Ella's grandmother Zelda Littlejohn gives ghost tours and knows a lot about ghosts. Angus' dad thinks Zelda is a witch. Ella thinks that maybe Zelda can help Jon with his ghost problem, and they agree to meet at Zelda's after school.
Zelda, very familiar with ghosts and how they operate because she's seen dozens in her lifetime, is alarmed when Jon tells her they called him Hartgill. In her card file of ghostly facts, she learns that in 1556, Lord Stourton and his four servants were hanged for the murder of Stourton's steward, William Hartgill and his son. Since that time, Stourton and his servants have taken revenge by killing anyone with the name of Hartgill. Zelda assures Jon that ghosts can't really harm him and that they only want attention — but one can never be too sure. She tells him to stay away from open windows. Ella tells him about a dead knight who will come to help when a person is in deep trouble and calls on him.
The long-dead knight is William Longspee, the illegitimate son of Henry the Second and half brother of Richard the Lionheart. He died before fulfilling his oath of protecting the innocent and the weak; the knight continues to attempt fulfillment of his oath by helping any desperate person who calls on him. Longspee's stone coffin is in the cathedral, and Ella convinces Jon to go there to get help from Longspee. But they have to go there when no one else is around, and the only way to accomplish that is to spend the night in the cathedral. She finds a small closet where they can hide, and they listen for the tourists to leave and the cathedral to close.
When the place is deserted, Jon and Ella walk to Longspee's sarcophagus, and Jon, though he thinks what they are doing is a stupid idea, kneels (because that is what you do with knights) near the head of the coffin and asks Longspee for help. Soon, Longspee's ghost appears. Jon and Ella explain the trouble Jon is having with the ghosts. Longspee presses a ring into Jon's palm, leaving an imprint of a lion. He tells Jon to close his fist over this crest the next time he sees the ghosts, and the knight will come to his aid. With that promise, Longspee disappears, and Ella and Jon fall asleep next to the sarcophagus.
A priest finds them the next morning. The school disciplines Jon with a weekend detention and a written essay assignment. While Jon and Ella are talking over their meeting with Longspee, two vicious ghost dogs abruptly appear and threaten them. Then the four ghosts riding their horses show up in a black fog along with Lord Stourton.
When Jon and Ella see them coming, Ella urges him to call Longspee. Jon closes his fist over the crest in his palm, and Longspee appears. Longspee and the five ghosts battle each other with their swords, and all sustain injuries. Just as Stourton raises his sword to strike Jon, Longspee's sword thrusts through his chest, and Stourton collapses at Jon's feet. As Jon and Ella watch Stourton dissolve, Longspee also fades away. The black fog disappears, the evening sun sets, and Ella and Jon return to regular life believing that Stourton is no longer a problem.
With his roommates gone for the weekend, Jon is alone that night. He decides to sneak over to the cathedral to talk with Longspee. When Longspee appears, Jon wishes Longspee would teach him about fighting. Longspee shows Jon how to melt into him so that for a brief time Jon can experience Longspee's vivid past in battle.
Afterward, Longspee tells Jon to forget about him. But Jon wants to do something for the knight to ease his sadness. Jon melts into Longspee again, becoming Longspee, and they suddenly are at Longspee's funeral. Jon learns who poisoned Longspee and how his wife planned to safeguard his heart. But the murderer killed a servant in order to swap that heart for Longspee's, and he hides Longspee's heart, thus dooming the knight's soul to eternal darkness. Longspee asks Jon to find his heart and bury it with his wife so he can fulfill his oath and see his wife again. Jon agrees.
While on a Monday morning bus excursion to historic Old Sarum, Jon goes into the chapel while his classmates go in another direction. The ghost of a chorister materializes and tells Jon that Longspee killed him and that Longspee can't be trusted. A teacher interrupts the conversation, and the chorister vanishes.
Jon suddenly realizes that Ella hasn't been in school, and he begins to suspect that something terrible has happened to her. Jon runs to Zelda's house and sees that Zelda has been crying. She has a note that says to bring Jon to the cemetery or Ella will be killed. Jon tells Zelda the truth about Longspee and the ghosts they fought. Zelda has never dealt with threatening ghosts, and now she is scared. Suddenly there is someone at the door, and Zelda is relieved to see it is her son, Matthew Littlejohn. Her son turns out to be The Beard, who he now understands is Ella's uncle, as well as Zelda's son.
Jon, Zelda and Matthew go to the cemetery armed with Matthew's rifle and Zelda's crutches. The ghosts appear with Ella. They capture Jon, Zelda and Matthew and plan to push Ella and Jon off a high tower. Jon summons Longspee, and he learns that Stourton is a "peeler." If another ghost kills Stourton, he sheds his skin and gets a new one. Jon also finds out that only a Hartgill can kill Stourton. Jon and Longspee melt into each other, and Jon, using Longspee's strength, finally kills Stourton. Longspee dispatches Stourton's remaining servant ghosts, thereby rescuing Zelda and Matthew as well.
The next day, Jon, Ella and Zelda go to the cathedral to talk to Longspee. They learn that it was true that he was indirectly responsible for the death of the chorister. They also learn that the chorister had hidden Longspee's heart. They next meet with the chorister, and Ella tricks him into showing her where the knight's heart is hidden.
Zelda drives Jon and Ella to Lacock Abbey so they can bury Longspee's heart near his wife's tombstone. When they finish, Longspee's wife's ghost appears across the courtyard. Jon summons Longspee, and he appears and finds his wife. They melt into each other.
Back with his roommates, Jon decides to tell them the truth about what has been happening. Angus wants to see a ghost, so the three boys sneak back into the cathedral. Longspee hears them talking and materializes to allow all three to see him. He also rouses the ghost of John Cheney so the boys can meet him. Jon and Longspee remain friends to the present, which is eight years later.
A few days later, Jon's mother comes to visit. He tries to maintain his formerly grumpy disposition around her, but finds he has started to like his new life in Salisbury. His mother has come to tell him that he can return home. She is no longer sure that Matthew is the right person for her. It seems that after a visit to his mother's, he's been acting strange — shaving off his beard and asking her all kinds of ghost and knight questions. He wants her to bury his heart in the garden after he dies. Jon tells her he sees nothing wrong with those questions, and he's OK with her marrying Matthew. His response thrills his mother. They end with a visit to Longspee's sarcophagus, and Jon tells her about his best friend, Ella.