Setting out again, Gulliver's ship is attacked by pirates, and he is marooned close to a desolate rocky island near India. He is rescued by the flying island of Laputa, a kingdom devoted to the arts of music, mathematics, and astronomy but unable to use them for practical ends. Rather than using armies, Laputa has a custom of throwing rocks down at rebellious cities on the ground.
Gulliver tours Balnibarbi, the kingdom ruled from Laputa, as the guest of a low-ranking courtier and sees the ruin brought about by the blind pursuit of science without practical results, in a satire on bureaucracy and on the Royal Society and its experiments. At the Grand Academy of Lagado in Balnibarbi, great resources and manpower are employed on researching preposterous schemes such as extracting sunbeams from cucumbers, softening marble for use in pillows, learning how to mix paint by smell, and uncovering political conspiracies by examining the excrement of suspicious persons (see muckraking). Gulliver is then taken to Maldonada, the main port of Balnibarbi, to await a trader who can take him on to Japan.
While waiting for a passage, Gulliver takes a short side-trip to the island of Glubbdubdrib which is southwest of Balnibarbi. On Glubbdubdrib, he visits a magician's dwelling and discusses history with the ghosts of historical figures, the most obvious restatement of the "ancients versus moderns" theme in the book. The ghosts include Julius Caesar, Brutus, Homer, Aristotle, René Descartes, and Pierre Gassendi.
On the island of Luggnagg, he encounters the struldbrugs, people who are immortal. They do not have the gift of eternal youth, but suffer the infirmities of old age and are considered legally dead at the age of eighty.
After reaching Japan, Gulliver asks the Emperor "to excuse my performing the ceremony imposed upon my countrymen of trampling upon the crucifix", which the Emperor does. Gulliver returns home, determined to stay there for the rest of his days.