Plot
Young Kevin is fascinated by history, particularly Ancient Greece, while his parents are obsessed only with modern consumerism and buying the latest household gadgets. One night, Kevin sees an armoured knight on horseback burst out of his wardrobe, then ride off into a forest where his bedroom wall was. The room returns to normal, leaving a photo on the wall similar to the forest he saw; the next night he prepares supplies and a Polaroid camera ready for a repeat viewing, but instead six dwarfs - Fidgit, Strutter, Og, Wally, Vermin and their leader, Randall - spill out of the wardrobe. The group have stolen a map and are looking for an exit from Kevin's room before they are discovered. After they reveal a long corridor leading to a portal, Kevin hesitates to join them until the apparition of a floating, menacing head—the Supreme Being—appears, demanding the map's return.
Kevin follows the group through the portal and lands with them in Italy during the Battle of Castiglione. Kevin learns that the Supreme Being once employed the dwarfs to repair holes in the spacetime fabric, but they realised the potential to use the map of the holes to steal riches from different time periods. With Kevin's help, they visit several locations in spacetime and meet Napoleon Bonaparte and Robin Hood, while Kevin uses his camera to document their visits. However, they are unaware that their activities are being monitored by Evil, a malevolent being who can manipulate reality and is attempting to acquire the map.
Kevin becomes separated from the group and ends up in Mycenaean Greece, meeting King Agamemnon, who adopts Kevin after he inadvertently helps the king kill a Minotaur. Randall and the others soon locate Kevin and abduct him, much to his resentment, and escape through another hole to the RMS Titanic, which begins sinking. Evil manipulates the group and transports them to his realm, the Time of Legends. After surviving encounters with ogres and a giant, Kevin and the dwarfs locate the Fortress of Ultimate Darkness and are led to believe that "The Most Fabulous Object in the World" awaits them. Instead, Evil takes the map and locks the group in a cage over a bottomless pit. While looking through his Polaroids, Kevin finds one that includes the map, and the group realises that there is a hole near them. They escape from the cage, and Kevin distracts their pursuers while the others go through the hole.
Evil confronts Kevin when the dwarfs return with various warriors and fighting machines from across time, but Evil effortlessly and comically defeats them all. As Evil prepares to unleash his ultimate power, he is suddenly engulfed in flames; from the smoke, a besuited elderly man, revealed as the Supreme Being, emerges. He explains that he allowed the dwarfs to borrow his map, the whole adventure having been a test, and orders the dwarfs to collect the pieces of Evil's remains, warning that they can be deadly. After recovering the map, he allows the dwarfs to rejoin him in his creation duties, and disappears with the dwarfs, leaving Kevin behind as a missed piece of Evil begins to smoulder. Kevin awakens in his bedroom and is rescued by firefighters - the chief of which resembles Agamemnon - as they put out a fire in his house. As Kevin finds he still has the photos from his adventure, his parents discover a smouldering rock in the toaster oven - recognising it as a piece of Evil, Kevin warns them not to touch it, but they ignore him, do so, and explode, leaving only their shoes. As the chief firefighter winks at the boy before leaving, Kevin approaches the smoking shoes and is seen from above as his figure grows smaller, revealing the planet and outer space, before being rolled up in the map by the Supreme Being.