The book commences with the end of Charlie and the Chocolate Factory: Willy Wonka has just given Charlie the ownership of his chocolate factory, and they crash through the roof of the Chocolate Factory in a flying Elevator to inform his family of the good news. Charlie's grandparents (except Grandpa Joe, already mobile) after twenty years in bed, refuse to leave it, and the bed is carried in the Elevator itself. At a critical moment during the return trip to the factory, a panicking Grandma Josephine draws Wonka from the controls, and the Elevator is sent into an extra-atmospheric orbit, wherein it circles the Earth until Wonka sees the chance to link it with the newly launched Space Hotel'U.S.A.': a luxurious hotel with 500 rooms commissioned by the United States government.
In the White House, President of the United States Lancelot R. Gilligrass, Vice President Elvira Tibbs, the president's best friend, chiefs, and the U.S. Cabinet see the Elevator dock with the Space Hotel, and fear it contains hostile agents of a foreign or extraterrestrial government, while the space shuttle containing the hotel staff and three astronauts approaches the Space Hotel. On the Hotel, Wonka and the others hear the President address them across a radio link as Martians, and Wonka therefore teases Gilligrass with nonsense words and grotesque poetry. In the midst of this, the hotel's own elevators open, revealing five gigantic amoeba-like monsters, which change shape: each forming a letter of the word "SCRAM". Recognising the danger, Wonka orders everybody off the Space Hotel. These shape-changers, Wonka tells the others, are predatory extraterrestrials called Vermicious Knids, waiting in the Space Hotel to consume its staff and guests. Wonka also explains that the Knids have tried to invade Earth and consume it's inhabitants like they have done with many other planets (Mars, Venus and the Moon, among others) but are always incinerated because of the atmosphere protecting the planet.
Upon the Elevator's departure, the staff and astronauts go aboard, and the Knids consume 24 of the staff, while the others escape. Capable of flying in space at improbable speeds, the Knids dive-bomb the shuttle's engines and hull, destroying the rockets, the cameras, and the radio antenna, apparently dooming the occupants to a lifetime stranded in space. Seeing all this from the "Knidproof" Great Glass Elevator, Charlie suggests that he and his companions to tow the shuttle back to Earth. In agreement, Wonka pilots the Elevator into range, whereupon Charlie's Grandpa Joe connects the two vessels by means of a steel cord. The Knids change into living segments of a towing line, with which to capture the two spacecraft, while a single Knid wraps his body around the Elevator to provide an anchor for this operation; whereupon Willy Wonka returns the Elevator to Earth, and the Knids are incinerated in the atmosphere. At the right moment, Wonka releases the shuttle, which floats safely home. The Elevator then crashes into the chocolate factory.
Though requested by Charlie, his grandparents Georgina, George, and Josephine still refuse to move out of their bed, and Wonka prescribes a rejuvenation formula, called 'Wonka-Vite'. The three bedridden recipients take much more than they need, and lose eighty years: making George one year old, Josephine three months, and Georgina absent altogether (Due to her being only seventy-eight and thus reverting to an 'age' of minus two). Accordingly, Charlie and Wonka journey in the Great Glass Elevator to "Minusland" (a limbo containing those subject of Georgina's transformation, discovered by Wonka when his initial experiments to create Wonka-Vite were too powerful), where Wonka restores her with "Vita-Wonk", a sprayable compound that makes people older. Upon her return, Georgina has become 358 years old, and her memory entails a long history beginning with the voyage in the ship "Mayflower" and ending in the present moment. Using a more cautious dose of Wonka-Vite, her companions restore her correct age of 78; and with this done, Charlie and Mr. Wonka recall Josephine and George to their original age.
Upon the arrival of messengers, the Oompa-Loompas give Wonka a letter from President Gilligrass, congratulating the occupants of the Great Glass Elevator on saving the lives of the shuttle astronauts and hotel staff and inviting them as the guests of honor to a White House dinner. The grandparents therefore leap out of bed and join Charlie, Grandpa Joe, Wonka, and Charlie's parents to enter the helicopter sent to obtain them.