The story follows Irene, a young princess living in a grand palace on a great mountainous country. While exploring the old house on a rainy day, she discovers a hidden staircase leading to her great-great-grandmother, a wise old queen who spins mysterious spider-web thread and possesses a magical lamp. Meanwhile, deep beneath the mountains, a subterranean race of grotesque goblins plots revenge against the surface-dwelling people who displaced them.
Irene soon meets Curdie, a brave young miner who understands the threat posed by the goblins. Curdie discovers their tunnels and overhears their plans to inundate the mine and harass the king's household. When the goblins attempt to invade the king's house and capture Irene, Curdie and the loyal men-at-arms fight them off, while Irene uses her grandmother's magical thread to navigate danger and find safety.
Throughout these adventures, Irene learns the importance of faith and truth, while Curdie gradually learns to believe in things that lie beyond the reach of ordinary sight. With the help of the mysterious queen and Curdie's quick thinking, the goblin invasion is thwarted when their own floodwaters trap them. The king returns, peace is restored to the mountain, and a lasting bond is forged between the princess and the young miner.