The story is told by a narrator who claims to have known Lothar. It begins by quoting three letters:
1. A letter from Nathanael to Lothar, the brother of his fiancée, Klara. Nathanael recalls his childhood terror of the legendary Sandman, who was said to steal the eyes of children who would not go to bed and feed them to his own children who lived in the moon. Nathanael came to associate the Sandman with a mysterious nightly visitor to his father. He recounts that one night, he hid in his father's room to see the Sandman. It is Coppelius, an obnoxious lawyer come to carry out alchemical experiments. Coppelius begins taking "shining masses" out of the fire and hammering them into face-like shapes without eyes. When Nathanael screams and is discovered, Coppelius flings him to the hearth. He is about to throw fire embers into Nathanael's eyes when his father pleads he be permitted to keep his eyes. Coppelius instead twists Nathanael's hands and feet and tortures him until he passes out. A year later, another night of experiments caused his father's death in the presence of Coppelius, who then vanished without a trace. His father having died of some sort of flaming explosion, the burns to his face are gone before he is laid in his coffin. Nathanael believes that a barometer-seller who arrived recently at his rooms under the name Giuseppe Coppola is none other than the hated Coppelius, and he is determined to seek vengeance.
2. A letter from Klara to Nathanael, explaining that Nathanael had addressed the previous letter to her instead of to Lothar. She was touched at the account of Nathanael's childhood trauma, and discussed it with Lothar, but she is convinced that the terrors are of Nathanael's own imagining and urges him to put Coppelius/Coppola out of his mind.
3. A letter from Nathanael to Lothar, in which Nathanael declares that Coppola is not, after all, Coppelius: Coppola is clearly Italian, while Coppelius was German, and Coppola is also vouched for by the new physics professor, Spallanzani, who is also Italian and has known Coppola for years. Nathanael adds that Spallanzani has a daughter, Olimpia, a brief glimpse of whom has made a considerable impression upon him.
Shortly after this third letter, Nathanael returns to his home town from his studies to see Klara and Lothar, and in the joy of their reunion Coppelius/Coppola is at first forgotten. Nevertheless, the encounter with Coppola has had a profound effect on Nathanael, driving him toward a gloomy mysticism which bores Klara and leads to their gradual estrangement. He writes a poem about Coppelius destroying his happiness in love, in which Coppelius appears at his wedding to touch Klara's eyes and then throws Nathanael into a circle of fire. After he emotionally reads this poem to her, she tells him to throw the insane poem into the fire. Nathanael's frustration with this leads him to call her an "inanimate, accursed automaton", which so enrages Lothar that he in turn insults Nathanael, and a duel is only narrowly averted by Klara's intervention. Nathanael pleads for Klara's forgiveness, and declares his true love for her, and the three then reconcile.
Nathanael returns to complete the final year of his studies, after which he intends to return to his hometown forever. He finds his student lodgings destroyed by fire, though his possessions were rescued by his friends and moved to a new house which is opposite that of Spallanzani. His window now looks directly into that of Olimpia, and he is again struck by her beauty. Coppola calls to sell his wares, and offers "pretty eyes, pretty eyes!" which reawakens Nathanael's childish fear of the Sandman. However, it turns out that Coppola has lenses and spectacles to sell, and also small telescopes, and Nathanael buys one of these from him to set matters right after his earlier outburst. As Coppola leaves, Nathanael becomes fixated on watching Olimpia through his telescope, although her fixed gaze and motionless stance disconcert him.
Spallanzani gives a grand party at which it is reported that his daughter will be presented in public for the first time. Nathanael is invited, and becomes enraptured by Olimpia, who plays the harpsichord, sings and dances. Her stiffness of movement and coldness of touch appear strange to many of the company. Nathanael dances with her repeatedly, awed by her perfect rhythm, and eventually tells her of his passion for her, to which Olimpia replies only "Ah, ah!". During the following days, he visits Olimpia repeatedly, reading her the poems and mysticism that had so bored Klara, and Olimpia listens to it all and replies only "Ah, ah!", which Nathanael interprets as understanding. Most other people consider her dull and stupid, although pretty, and with strangely mechanical actions.
Eventually Nathanael determines to propose to Olimpia, but when he arrives at her rooms he finds an argument in progress between Spallanzani and Coppola, who are fighting over the body of Olimpia and arguing over who made the eyes and who made the clockwork. Coppola, who is now revealed as Coppelius in truth, wins the struggle, and makes off with the lifeless and eyeless body, while the injured Spallanzani urges Nathanael to chase after him and recover the automaton to which he has devoted so many years of his life. The sight of Olimpia's eyes lying on the ground drives Nathanael to madness, and he flies at the professor to strangle him. He is pulled away by other people drawn by the noise of the struggle, and in a state of insanity, is taken to an asylum.
Spallanzani recovers from the encounter, but is forced to leave the university because of the sensational revelation of the trick he had played in trying to pass off an automaton as a living person. Coppelius once more vanishes without trace. The narrator adds that the story of the automaton had a widespread effect on society, with many lovers taking steps to ensure they were not enamored of puppets but of real flesh and blood.
Nathanael appears to recover from his madness and is reunited with Klara and Lothar. He resolves to marry Klara and move to a pleasant estate near his home town. On the way to visit the place, they pass through the town and climb the high steeple to look out at the view. Klara points out a bush that seems to be striding towards them. Nathanael automatically withdraws Coppola's spyglass and, looking through it sideways, sees Klara through the lens. With Klara in place of Olimpia as the subject of the spyglass's gaze, madness strikes Nathanael again, and he tries to hurl Klara from the steeple. She is saved by Lothar, but in the crowd that gathers below Coppelius appears, and upon seeing him Nathanael cries "pretty eyes, pretty eyes!" and leaps over the railing to his death. Coppelius disappears into the crowd.
Many years afterward, the narrator concludes, it is said that Klara was seen with a kind-looking man sitting before a country house with two lively boys, and thus found the domestic happiness that Nathanael could never have provided.