The story begins on Christmas Eve at the Stahlbaum house. Marie, seven, and her brother, Fritz, eight, sit outside the parlor speculating about what kind of present their godfather, Drosselmeyer, who is a clockmaker and inventor, has made for them. They are at last allowed in, where they receive many splendid gifts, including Drosselmeyer's, which turns out to be a clockwork castle with mechanical people moving about inside it. However, as they can only do the same thing over and over without variation, the children quickly tire of it. At this point, Marie notices a nutcracker, and asks whom he belongs to. Her father tells her that he belongs to all of them, but that since she is so fond of him she will be his special caretaker. She, Fritz, and their sister, Louise, pass him among them, cracking nuts, until Fritz tries to crack one that is too big and hard, and the nutcracker's jaw breaks. Marie, upset, takes him away and bandages him with a ribbon from her dress.
When it is time for bed, the children put their Christmas gifts away in the special cabinet where they keep their toys. Fritz and Louise go up to bed, but Marie begs to be allowed to stay with the nutcracker a while longer, and she is allowed to do so. She puts him to bed and tells him that Drosselmeyer will fix his jaw as good as new. At this, his face seems momentarily to come alive, and Marie is frightened, but she then decides it was only her imagination.
The grandfather clock begins to chime, and Marie believes she sees Drosselmeyer sitting on top of it, preventing it from striking. Mice begin to come out from beneath the floor boards, including the seven-headed Mouse King. The dolls in the toy cabinet come alive and begin to move, the nutcracker taking command and leading them into battle after putting Marie's ribbon on as a token. The battle goes to the dolls at first, but they are eventually overwhelmed by the mice. Marie, seeing the nutcracker about to be taken prisoner, takes off her slipper and throws it at the Mouse King. She then faints into the toy cabinet's glass door, cutting her arm badly.
Marie wakes up in her bed the next morning with her arm bandaged and tries to tell her parents about the battle between the mice and the dolls, but they do not believe her, thinking that she has had a fever dream caused by the wound she sustained from the broken glass. Several days later, Drosselmeyer arrives with the nutcracker, whose jaw has been fixed, and tells Marie the story of Princess Pirlipat and Madam Mouserinks, who is also known as the Queen of the Mice, which explains how nutcrackers came to be and why they look the way they do.
The Mouse Queen tricked Pirlipat's mother into allowing the Mouse Queen and her children to gobble up the lard that was supposed to go into the sausage that the King was to eat at dinner that evening. The King, enraged at the Mouse Queen for spoiling his supper and upsetting his wife, had his court inventor, whose name happens to be Drosselmeyer, create traps for the Mouse Queen and her children.
The Mouse Queen, angered at the death of her children, swore that she would take revenge on Pirlipat. Pirlipat's mother surrounded her with cats which were supposed to be kept awake by being constantly stroked, however inevitably the nurses who did so fell asleep and the Mouse Queen magically turned Pirlipat ugly, giving her a huge head, a wide grinning mouth, and a cottony beard like a nutcracker. The King blamed Drosselmeyer and gave him four weeks to find a cure. At the end, he had no cure but went to his friend, the court astrologer.
They read Pirlipat's horoscope and told the King that the only way to cure her was to have her eat the nut Crackatook (Krakatuk), which must be cracked and handed to her by a man who had never been shaved nor worn boots since birth, and who must, without opening his eyes hand her the kernel and take seven steps backwards without stumbling. The King sent Drosselmeyer and the astrologer out to look for both, charging them on pain of death not to return until they had found them.
The two men journeyed for many years without finding either the nut or the man, until finally they returned home to Nuremberg and found the nut in the possession of Drosselmeyer's cousin, a puppet-maker. His son turned out to be the young man needed to crack the nut Crackatook. The King, once the nut had been found, promised Pirlipat's hand to whoever could crack it. Many men broke their teeth on it before Drosselmeyer's nephew finally appeared. He cracked it easily and handed it to Pirlipat, who swallowed it and immediately became beautiful again, but Drosselmeyer's nephew, on his seventh backward step, stepped on the Mouse Queen and stumbled, and the curse fell on him, giving him a large head, wide grinning mouth, and cottony beard; in short, making him a nutcracker. The ungrateful Pirlipat, seeing how ugly he had become, refused to marry him and banished him from the castle.
Marie, while she recuperates from her wound, hears the Mouse King, son of the deceased Madam Mouserinks, whispering to her in the middle of the night, threatening to bite the nutcracker to pieces unless she gives him her sweets and dolls. For the nutcracker's sake, she sacrifices them, but then he wants more and more and finally the nutcracker tells her that if she will just get him a sword, he will finish him off. She asks Fritz for one, and he gives her the one from one of his toy hussars. The next night, the nutcracker comes into Marie's room bearing the Mouse King's seven crowns, and takes her away with him to the doll kingdom, where she sees many wonderful things. She eventually falls asleep in the nutcracker's palace and is brought back home. She tries to tell her mother what happened, but again she is not believed, even when she shows her parents the seven crowns, and she is forbidden to speak of her "dreams" anymore.
Marie sits in front of the toy cabinet one day while Drosselmeyer is repairing one of her father's clocks. While looking at the nutcracker and thinking about all the wondrous things that happened, she can't keep silent anymore and swears to him that if he were ever really real she would never behave as Pirlipat did, and would love him whatever he looked like. At this, there is a bang and she faints and falls off the chair. Her mother comes in to tell her that Drosselmeyer's nephew has arrived from Nuremberg. He takes her aside and tells her that by swearing that she would love him in spite of his looks, she broke the curse on him and made him human again. He asks her to marry him. She accepts, and in a year and a day he comes for her and takes her away to the doll kingdom, where she marries him and is crowned queen.