In 1757, Moonfleet is a small village near the sea in the south of England. It gets its name from a formerly prominent local family, the Mohunes, whose coat of arms includes a symbol shaped like a capital 'Y'. John Trenchard is an orphan who lives with his aunt, Miss Arnold. Other notable residents are the sexton Mr Ratsey, who is friendly to John; Parson Glennie, the local clergyman who also teaches in the village school; Elzevir Block, the landlord of the local inn, called the Mohune Arms but nicknamed the Why Not? because of its sign with the Mohune 'Y'; and Mr Maskew, the unpopular local magistrate and his beautiful daughter, Grace.
Village legend tells of the notorious Colonel John "Blackbeard" Mohune who is buried in the family crypt under the church. He is reputed to have stolen a diamond from King Charles I and hidden it. His ghost is said to wander at night looking for it and the mysterious lights in the churchyard are attributed to his activities.
As the main part of the story opens, Block's youthful son, David, has just been killed by Maskew during an attack by the authorities on a smuggling boat. One night a bad storm hits the village and there is a flood. While attending the Sunday service at church, John hears strange sounds from the crypt below. He thinks it is the sound of the coffins of the Mohune family. The next day, he finds Elzevir and Ratsey against the south wall of the church. They claim to be checking for damage from the storm, but John suspects they are searching for Blackbeard's ghost.
Later John finds a large sinkhole has opened in the ground by a grave. He follows the passage and finds himself in the crypt with coffins on shelves and casks on the floor. He realises his friends are smugglers and this is their hiding place. He has to hide behind a coffin when he hears Ratsey and Elzevir coming. When they leave, they fill in the hole, inadvertently trapping him. John finds a locket in a coffin which holds a piece of paper with verses from the Bible. John eventually passes out after drinking too much of the wine while trying to quench his thirst, having not eaten or drunk for days. Later he wakes up in the Why Not? inn - he has been rescued by Elzevir and Ratsey. When he is better, he returns to his aunt's house, but she, suspecting him of drunken behaviour, throws him out. Fortunately, Elzevir takes him in.
But when Block's lease on the Why Not? comes up for renewal, Maskew bids against him in the auction and wins. Block must leave the inn and Moonfleet but plans one last smuggling venture. John feels honour-bound to go with him, and sadly, says goodbye to Grace Maskew, whom he loves and has been seeing in secret, and gets his mother's prayer book as a good luck charm. The excisemen and Maskew are aware of the planned smuggling run but do not know exactly where it will occur. During the landing Maskew appears and is caught by the smugglers. Elzevir is bent on vengeance for his son by killing Maskew, and while the rest land the cargo and leave, he and John keep watch over Maskew. Just as Block prepares to shoot Maskew the excisemen attack. They wound John and unintentionally kill Maskew. Block carries John away to safety and they hide in some old quarries. While there, John inadvertently finds out that the verses from Blackbeard's locket contain a code which will reveal the location of his famous diamond.
Once John's wound heals, he and Block decide to recover the diamond from Carisbrooke Castle. After a suspenseful scene in the well where the jewel is hidden, they succeed in escaping to Holland where they try to sell it to a Jewish diamond merchant named Crispin Aldobrand. The merchant cheats them, claiming the diamond is fake. Elzevir falls for the deceit and angrily throws the diamond out of the window. John, however, knows they have been duped, and suggests they try to recover the diamond through burglary. The attempt fails and, they are arrested and sentenced to prison. John curses the merchant for his lies.
John and Elzevir go to prison for life. Eventually they are separated. Then, unexpectedly, ten years later, their paths cross again. They are being transported, and board a ship. A storm blows up, and by a strong coincidence, the ship is wrecked upon Moonfleet beach. While trying to reach the beach Elzevir helps John to safety, but is himself dragged under by the tide and drowned.
John arrives where he originally started, in the Why Not?, and is reunited with Ratsey. He is also reunited with Grace. She is now a rich young lady, having inherited her father's money. However, she is still in love with John, and they decide to marry. John tells her about the diamond and his life in prison. He regrets having lost everything, but then Parson Glennie receives a letter from Aldobrand. The merchant suffered a guilty conscience, and in an attempt to make amends, has bequeathed the worth of the diamond to John.
John gives the money to the village, and new almshouses are built, and the school and the church renovated. John marries Grace and becomes Lord of the Manor and Justice of the Peace. Their three children grow up and their sons leave home, including their first-born son, Elzevir. But John and Grace themselves have no plans to leave their beloved Moonfleet ever again.

Question: What happens when John and Elzevir try to get the diamond back?
Answer: They are sentenced to prison for life.