The literary genre of science fiction is diverse, and its exact definition remains a contested question among both scholars and devotees. This lack of consensus is reflected in debates about the genre's history, particularly over determining its exact origins.
Some writers have identified precursors to the genre in ancient literature such as the Sumerian Epic of Gilgamesh (earliest Sumerian text versions c. 2150–2000 BCE). Others argue that science fiction only became possible sometime between the 17th and early 19th centuries, following the Scientific Revolution and major discoveries in astronomy, physics, and mathematics.
Science fiction developed and boomed in the 20th century, as the deep integration of science and inventions into daily life encouraged a greater interest in literature that explores the relationship between technology, society, and the individual. Scholar Robert Scholes calls the history of science fiction "the history of humanity's changing attitudes toward space and time ... the history of our growing understanding of the universe and the position of our species in that universe". In recent decades, the genre has diversified and become firmly established as a major influence on global culture and thought.
Early science fiction Ancient and early modern precursors
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 BCE. 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 a 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.
Ancient Indian poetry such as the Hindu epic the Ramayana (5th to 4th century BCE) 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 BCE), 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 BCE) 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.
One frequently cited text is the Syrian-Greek writer Lucian of Samosata'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 , 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" and Lucian translator Bryan Reardon describes 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 involves traveling forwards in time to a distant future, and was first described in the Nihongi (written in 720). It was about a young fisherman named Urashima Tarō who visits an undersea palace and stays there for three days. After returning home to his village, he finds himself 300 years in the future, where he is long forgotten, his house is 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 extraterrestrial 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 centuries 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 (Islamic hell), 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 jinn, 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 the biblical King 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. (cf. ) Other examples of early Arabic proto-science fiction include al-Farabi's Opinions of the Residents of a Splendid City about a utopian society, and certain Arabian Nights elements such as the flying carpet.
Other medieval literature According to Dr. Abu Shadi al-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 pulmonary circulation in order to explain bodily resurrection. The novel was later translated into English as 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 and Enéas among the first. The , 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 , 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 into it. 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 , 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 construct 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 and the . 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.E. R. Truitt (2009). The Virtues of Balm in Medieval Literature, 727–28