The story starts by vaguely introducing a fourteen-year-old nameless boy, who at the beginning has no parents and is a mute. He is apparently running away from his life as an abused orphan, and accidentally slips on the Flying Dutchman as a stowaway. He is found, and made to work with the cook, Petros, an antagonistic character who abuses him. Petros names the boy Neb, which is short for Nebuchadnezzar. One day, while the crew is off drinking in the port town of Esbjerg, a dog wanders onto the ship and is befriended by Neb. He names the dog Denmark, after the country he found the dog in. They strike up an immediate friendship. Den hides under sacks until it is safe to come out. The cruel, wild, and fearsome Captain Vanderdecken steers his ship on a long voyage to get emeralds from a dealer across the ocean, supposedly in Asia. The ship sails to the tip of South America, the treacherous Cape Horn, and unsuccessfully attempts to pass three times. After the third attempt, Captain Vanderdecken curses the Lord for smiting him, and an angel descends from heaven and curses the ship to sail the seas for eternity.
The angel, however, realizes Nebuchadnezzar and Denmark are pure of heart and not part of the motley, now undead, crew, and has them swept overboard by a great wave. S/he blesses them, telling them to walk the earth forever, wise and forever young, to give kindness and guidance wherever they go. They later wash up on shore and find that they are able to communicate by thought. They are found and taken in by a kind-hearted shepherd named Luis who grows fond of them, but does not ask about their past. After spending three years with him, Luis dies in a storm trying to save an ewe. The angel appears in a dream telling them that they must move on at the sound of a bell, which they hear jingling on the neck of a sheep walking by. Neb and Den, young but ageless, must leave.
The story picks up many years later. Both characters have changed their names (by reversing them); Neb is now Ben and Den is Ned. It is apparent that they have lived with each other for several centuries. One day, they get on a train without knowing where they are going, and end up getting off at the village of Chapelvale. They meet a lady named Mrs. Winn as well as a boy named Alex and a girl named Amy. The children warn them about the Grange Gang, a group of local bullies. The gang leader, Wilf, takes an immediate disliking to Ben.
Together Ben, Ned, Amy, Alex, and Mrs. Winn go on a treasure hunt to save the town, which is about to be converted into a limestone quarry and cement factory. They team up with an old ship's carpenter named Jon (who is at first believed to be a madman), a milkman named Will, and Will's family. They follow a series of clues written by Mrs. Winn's ancestor, who was believed to have been given the deeds to the town. One clue leads to a treasure (which is a Byzantine artifact) and another clue and continues that way until three treasures and clues have been found. The last clue, of course, is the hardest and is the last thing that may show them the location of the deeds to Chapelvale.
The deeds to the village are found and Mrs. Winn is able to claim Chapelvale as her property so that it can be saved. However, the angel appears once again and informs Ben and Ned that they must leave Chapelvale and their friends at the sound of a bell. Jon finds a bell in the Almshouse and becomes excited about the discovery. He and Will decide to try the bell out. Ben and Ned run as fast as they can, hoping that if they cannot hear the bell they will not have to leave, but they cannot get away in time and they must move on.