Early science fiction
Ancient and early modern precursors
There are a number of ancient or early modern texts including a great many epics and poems that contain fantastical or "science-fictional" elements, yet were written before the emergence of science fiction as a distinct genre. These texts often include elements such as a fantastical voyage to the moon or the use of imagined advanced technology. Although fantastical and science fiction-like elements and imagery exist in stories such as Ovid's Metamorphoses (8 AD), the Old English epic heroic poem Beowulf (8th-11th centuries AD), and the Middle German epic poem Nibelungenlied (c. 1230), their relative lack of references to science or technology puts them closer to fantasy rather than science fiction.
One of the earliest and most commonly-cited texts for those looking for early precursors to science fiction is the ancient Mesopotamian Epic of Gilgamesh, with the earliest text versions identified as being from about 2000 BC. American science fiction author Lester del Rey was one such supporter of using Gilgamesh as an origin point, arguing that "science fiction is precisely as old as the first recorded fiction. That is the Epic of Gilgamesh." French science fiction writer Pierre Versins also argued that Gilgamesh was the first science fiction work due to its treatment of human reason and the quest for immortality. In addition, Gilgamesh features a flood scene that in some ways resembles work of apocalyptic science fiction. However, the lack of explicit science or technology in the work has led some to argue that it is better categorized as fantastic literature.
1923 Illustration of the Shakuna Vimana
Ancient Indian poetry such as the Hindu epic Ramayana (5th to 4th century BC) includes Vimana flying machines able to travel into space or under water, and destroy entire cities using advanced weapons. In the first book of the Rigveda collection of Sanskrit hymns (1700–1100 BC), there is a description of "mechanical birds" that are seen "jumping into space speedily with a craft using fire and water... containing twelve stamghas (pillars), one wheel, three machines, 300 pivots, and 60 instruments."
The ancient Hindu mythological epic, the Mahabharata (8th and 9th centuries BC) includes the story of King Kakudmi, who travels to heaven to meet the creator Brahma and is shocked to learn that many ages have passed when he returns to Earth, anticipating the concept of time travel.
Ancient Greek playwright Aristophanes has several works that include elements often associated with the "fantastic voyage", including air travel to another world. Examples include his The Clouds (423 BC), The Birds (414 BC) and The Peace.
Aubrey Beardsley illustration of Lucian's interplanetary giant spider battle
One frequently cited text is the Syrian-Greek writer Lucian's 2nd-century satire True History, which uses a voyage to outer space and conversations with alien life forms to comment on the use of exaggeration within travel literature and debates. Typical science fiction themes and topoi in True History include travel to outer space, encounter with alien life-forms (including the experience of a first encounter event), interplanetary warfare and planetary imperialism, motif of giganticism, creatures as products of human technology, worlds working by a set of alternative physical laws, and an explicit desire of the protagonist for exploration and adventure. In witnessing one interplanetary battle between the People of the Moon and the People of the Sun as the fight for the right to colonize the Morning Star, Lucian describes giant space spiders who were "appointed to spin a web in the air between the Moon and the Morning Star, which was done in an instant, and made a plain campaign upon which the foot forces were planted..." L. Sprague de Camp and a number of other authors argue this to be one of the earliest if not the earliest example of science fiction or proto-science fiction.
 However, since the text was intended to be explicitly satirical and hyperbolic, other critics are ambivalent about its rightful place as a science fiction precursor. For example, English critic Kingsley Amis wrote that "It is hardly science-fiction, since it deliberately piles extravagance upon extravagance for comic effect" yet he implicitly acknowledged its SF character by comparing its plot to early 20th-century space operas: "I will merely remark that the sprightliness and sophistication of True History make it read like a joke at the expense of nearly all early-modern science fiction, that written between, say, 1910 and 1940." Lucian translator Bryan Reardon is more explicit, describing the work as "an account of a fantastic journey - to the moon, the underworld, the belly of a whale, and so forth. It is not really science fiction, although it has sometimes been called that; there is no 'science' in it."
The early Japanese tale of "Urashima Tarō" involves traveling forwards in time to a distant future, and was first described in the Nihongi (720). It was about a young fisherman named Urashima Taro who visits an undersea palace and stays there for three days. After returning home to his village, he finds himself three hundred years in the future, where he is long forgotten, his house in ruins, and his family long dead. The 10th-century Japanese narrative The Tale of the Bamboo Cutter may also be considered proto-science fiction. The protagonist of the story, Kaguya-hime, is a princess from the Moon who is sent to Earth for safety during a celestial war, and is found and raised by a bamboo cutter in Japan. She is later taken back to the Moon by her real family. A manuscript illustration depicts a round flying machine similar to a flying saucer.
One Thousand and One Nights
Several stories within the One Thousand and One Nights (Arabian Nights, 8th-10th century CE) also feature science fiction elements. One example is "The Adventures of Bulukiya", where the protagonist Bulukiya's quest for the herb of immortality leads him to explore the seas, journey to the Garden of Eden and to Jahannam, and travel across the cosmos to different worlds much larger than his own world, anticipating elements of galactic science fiction; along the way, he encounters societies of jinns, mermaids, talking serpents, talking trees, and other forms of life.
In "Abdullah the Fisherman and Abdullah the Merman", the protagonist gains the ability to breathe underwater and discovers an underwater submarine society that is portrayed as an inverted reflection of society on land, in that the underwater society follows a form of primitive communism where concepts like money and clothing do not exist.
Other Arabian Nights tales deal with lost ancient technologies, advanced ancient civilizations that went astray, and catastrophes which overwhelmed them. "The City of Brass" features a group of travellers on an archaeological expedition across the Sahara to find an ancient lost city and attempt to recover a brass vessel that Solomon once used to trap a jinn, and, along the way, encounter a mummified queen, petrified inhabitants, lifelike humanoid robots and automata, seductive marionettes dancing without strings, and a brass robot horseman who directs the party towards the ancient city.
"The Ebony Horse" features a robot in the form of a flying mechanical horse controlled using keys that could fly into outer space and towards the Sun, while the "Third Qalandar's Tale" also features a robot in the form of an uncanny sailor. "The City of Brass" and "The Ebony Horse" can be considered early examples of proto-science fiction. Other examples of early Arabic proto-science fiction include al-Farabi's Opinions of the residents of a splendid city about a utopian society, Zakariya al-Qazwini's futuristic tale of Awaj bin Anfaq about a man who travelled to Earth from a distant planet, and certain Arabian Nights elements such as the flying carpet.
Other medieval literature
According to Roubi, the final two chapters of the Arabic theological novel Fādil ibn Nātiq (c. 1270), also known as Theologus Autodidactus, by the Arabian polymath writer Ibn al-Nafis (1213–1288) can be described as science fiction. The theological novel deals with various science fiction elements such as spontaneous generation, futurology, apocalyptic themes, eschatology, resurrection and the afterlife, but rather than giving supernatural or mythological explanations for these events, Ibn al-Nafis attempted to explain these plot elements using his own extensive scientific knowledge in anatomy, biology, physiology, astronomy, cosmology and geology. For example, it was through this novel that Ibn al-Nafis introduces his scientific theory of metabolism, and he makes references to his own scientific discovery of the pulmonary circulation in order to explain bodily resurrection. The novel was later translated into English as Theologus Autodidactus in the early 20th century.
During the European Middle Ages, science fictional themes appeared within many chivalric romance and legends. Robots and automata featured in romances starting in the twelfth century, with Le Pèlerinage de Charlemagne and Eneas among the first. The Roman de Troie, another twelfth-century work, features the famous Chambre de Beautes, which contained four automata, one of which held a magic mirror, one of which performed somersaults, one of which played musical instruments, and one which showed people what they most needed. Automata in these works were often ambivalently associated with necromancy, and frequently guarded entrances or provided warning of intruders. This association with necromancy often leads to the appearance of automata guarding tombs, as they do in Eneas, Floris and Blancheflour, and Le Roman d’Alexandre, while in Lancelot they appear in an underground palace. Automata did not have to be human, however. A brass horse is among the marvelous gifts given to the Cambyuskan in Geoffrey Chaucer's "The Squire's Tale". This metal horse is reminiscent of similar metal horses in middle eastern literature, and could take its rider anywhere in the world at extraordinary speed by turning a peg in its ear and whispering certain words in its ear. The brass horse is only one of the technological marvels which appears in The Squire’s Tale: the Cambyuskan, or Khan also receives a mirror which reveals distant places, which the witnessing crowd explains as operating by the manipulation of angles and optics, and a sword which deals and heals deadly wounds, which the crowd explains as being possible using advanced smithing techniques.
Technological inventions are also rife in the Alexander romances. In John Gower's Confessio Amantis, for example, Alexander the Great constructs a flying machine by tying two griffins to a platform and dangling meat above them on a pole. This adventure is ended only by the direct intervention of God, who destroys the device and throws Alexander back to the ground. This does not, however, stop the legendary Alexander, who proceeds to have constructed a gigantic orb of glass which he uses to travel beneath the water. There he sees extraordinary marvels which eventually exceed his comprehension.
States similar to suspended animation also appear in medieval romances, such as the Histora Destructionis Troiae and the Roman d’Eneas. In the former, king Priam has the body of the hero Hector entombed in a network of golden tubes that run through his body. Through these tubes ran the semi-legendary fluid balsam which was then reputed to have the power to preserve life. This fluid kept the corpse of Hector preserved as if he was still alive, maintaining him in a persistent vegetative state during which autonomic processes such as the growth of facial hair continued.
The boundaries between medieval fiction with scientific elements and medieval science can be fuzzy at best. In works such as Geoffrey Chaucer "The House of Fame", it is proposed that the titular House of Fame is the natural home of sound, described as a ripping in the air, towards which all sound is eventually attracted, in the same way that the earth was believed to be the natural home of earth to which it was all eventually attracted. Likewise, medieval travel narratives often contained science-fictional themes and elements. Works such as Mandeville’s Travels included automata, alternate species and sub-species of humans, including Cynoencephali and Giants, and information about the sexual reproduction of diamonds. However, Mandeville’s Travels and other travel narratives in its genre mix real geographical knowledge with knowledge now known to be fictional, and it is therefore difficult to distinguish which portions should be considered science fictional or would have been seen as such in the Middle Ages.
Proto-science fiction in the Enlightenment and Age of Reason
In the wake of scientific discoveries that characterized the Enlightenment, several new types of literature began to take shape in 16th-century Europe. The humanist thinker Thomas More's 1516 work of fiction and political philosophy entitled Utopia describes a fictional island whose inhabitants have perfected every aspect of their society. The name of the society stuck, giving rise to the Utopia motif that would become so widespread in later science fiction to describe a world that is seemingly perfect but either ultimately unattainable or perversely flawed. The Faust legend (1587) contains an early prototype for the "mad scientist story" (and indeed would later be adapted as explicitly science fiction in the 1956 film Forbidden Planet).
Frontispiece of the 1659 German translation of Godwin's The Man in the Moone
In the 17th and 18th centuries, the so-called "Age of Reason" and widespread interest in scientific discovery fueled the creation of speculative fiction that anticipated many of the tropes of more recent science fiction. Several works expanded on imaginary voyages to the moon, first in Johannes Kepler's Somnium (The Dream, 1634), which both Carl Sagan and Isaac Asimov have referred to as the first work of science fiction. Similarly, some identify Francis Godwin's The Man in the Moone (1638) as the first work of science fiction in English, and Cyrano de Bergerac's Comical History of the States and Empires of the Moon (1656). Space travel also figures prominently in Voltaire's Micromégas (1752), which is also notable for the suggestion that people of other worlds may be in some ways more advanced than those of earth.
Other proto-science fiction from the Age of Reason of the 17th and 18th centuries includes (in chronological order):