Elements of the supernatural and the fantastic were an element of literature from its beginning, though the idea of a distinct genre, in the modern sense, is less than two centuries old.

Ancient

Near East

The Epic of Gilgamesh was written over generations following the supposed reign of King Gilgamesh, and is seen as a mythologized version of his life. This figure is sometimes an influence and, more rarely, a figure in modern fantasy.John Grant and John Clute, The Encyclopedia of Fantasy, "Gilgamesh", p. 410. .

Ancient India India has a long tradition of fantastical stories and characters, dating back to Vedic mythology. Several modern fantasy works such as RG Veda draw on the Rig-Veda as a source. Hindu mythology was an evolution of the earlier Vedic mythology and had many more fantastical stories and characters, particularly in the Indian epics, such as the Mahabharata by Vyasa, and the Ramayana by Valmiki, both of which were influential in Asia. The Panchatantra (Fables of Bidpai) was influential in Europe and the Middle East. It used various animal fables and magical tales to illustrate the central Indian principles of political science. Talking animals endowed with human qualities have now become a staple of modern fantasy.Richard Matthews (2002). Fantasy: The Liberation of Imagination, p. 8–10. Routledge. .

The Baital Pachisi (Vikram and the Vampire) is a collection of various fantasy tales set within a frame story about an encounter between King Vikramāditya and a Vetala, an early mythical creature resembling a vampire. According to Richard Francis Burton and Isabel Burton, the Baital Pachisi "is the germ which culminated in the Arabian Nights, and which inspired the Golden Ass of Apuleius, Boccacio's Decamerone, the Pentamerone, and all that class of facetious fictitious literature."Isabel Burton, Preface, in Richard Francis Burton (1870), Vikram and The Vampire.

Greco-Roman

Classical mythology is replete with fantastical stories and characters, the best known (and perhaps the most relevant to modern fantasy) being the works of Homer (Greek) and Virgil (Roman).John Grant and John Clute, The Encyclopedia of Fantasy, "Taproot texts", p 921

The contribution of the Greco-Roman world to fantasy is vast and includes: The hero's journey (also the figure of the chosen hero); magic gifts donated to win (including the ring of power as in the Gyges story contained in the Republic of Plato), prophecies (the oracle of Delphi), monsters and creatures (especially Dragons), magicians and witches with the use of magic.

The philosophy of Plato has had great influence on the fantasy genre. In the Christian Platonic tradition, the reality of other worlds, and an overarching structure of great metaphysical and moral importance, has lent substance to the fantasy worlds of modern works.Stephen Prickett, Victorian Fantasy p 229 The world of magic is largely connected with the Roman Greek world. With Empedocles, the elements, they are often used in fantasy works as personifications of the forces of nature.John Grant and John Clute, The Encyclopedia of Fantasy, "Elemental" p 313-4, Concerns other than magic include the use of a mysterious tool endowed with special powers (the wand); the use of a rare magical herb; and a divine figure that reveals the secret of the magical act.

Myths especially important for fantasy include: The myth of Titans; the Gods of Olympus; Pan; Theseus, the hero who killed the Minotaur (with the labyrinth); Perseus, the hero who killed Medusa ( with the gift of magic objects and weapons); Heracles is probably the best known Greek hero; Achilles; the riddling Sphinx; Odysseus; Ajax; Jason (of the Argonauts); Female sorcerers as well Circe, Calypso and goddess Hecate; Daedalus and Icarus.

Medieval

East Asia

The figures of Chinese dragons were influential on the modern fantasy use of the dragon, tempering the greedy, thoroughly evil, even diabolical Western dragon; many modern fantasy dragons are humane and wise.

Chinese traditions have been particularly influential in the vein of fantasy known as Chinoiserie, including such writers as Ernest Bramah and Barry Hughart.John Grant and John Clute, The Encyclopedia of Fantasy, "Chinoiserie", p 189

Taoist beliefs about neijin and its influence on martial arts have been a major influence on wuxia, a subgenre of the martial arts film that is sometimes fantasy, when the practice of wuxia is used fictitiously to achieve super-human feats, as in Crouching Tiger, Hidden Dragon.Eric Yin, "A Definition of Wuxia and Xia"

Islamic Middle East

The most well known fiction from the Islamic world was The Book of One Thousand and One Nights (Arabian Nights), which was a compilation of many ancient and medieval folk tales. The epic took form in the tenth century and reached its final form by the fourteenth century; the number and type of tales have varied from one manuscript to another.John Grant and John Clute, The Encyclopedia of Fantasy, "Arabian fantasy", p 51 All Arabian fairy tales were often called "Arabian Nights" when translated into English, regardless of whether they appeared in The Book of One Thousand and One Nights, in any version, and a number of tales are known in Europe as "Arabian Nights" despite existing in no Arabic manuscript.

This epic has been influential in the West since it was translated in the 18th century, first by Antoine Galland.L. Sprague de Camp, Literary Swordsmen and Sorcerers: The Makers of Heroic Fantasy, p 10 Many imitations were written, especially in France.John Grant and John Clute, The Encyclopedia of Fantasy, "Arabian fantasy", p 52 Various characters from this epic have themselves become cultural icons in Western culture, such as Aladdin, Sinbad and Ali Baba. Part of its popularity may have sprung from the increasing historical and geographical knowledge, so that places of which little was known and so marvels were plausible had to be set further "long ago" or farther "far away"; this is a process that continue, and finally culminate in the fantasy world having little connection, if any, to actual times and places.

A number of elements from Persian and Arabian mythology are now common in modern fantasy, such as genies, bahamuts, magic carpets, magic lamps, etc. When L. Frank Baum proposed writing a modern fairy tale that banished stereotypical elements, he included the genie as well as the dwarf and the fairy as stereotypes to go.James Thurber, "The Wizard of Chitenango", p 64 Fantasists on Fantasy edited by Robert H. Boyer and Kenneth J. Zahorski,

The Shahnameh, the national epic of Iran, is a mythical and heroic retelling of Persian history. Amir Arsalan was also a popular mythical Persian story.

Europe

Medieval European sources of fantasy occurred primarily in epic poetry and in the Fornaldarsagas, Norse and Icelandic sagas, both of which are based on ancient oral tradition. The influence of these works on the German Romantics, as well as William Morris, and J. R. R. Tolkien means that their influence on later fantasy has been large.John Grant and John Clute, The Encyclopedia of Fantasy, "Nordic fantasy", p 692

Anglo-Saxon

Beowulf is among the best known of the Nordic tales in the English speaking world, and has had deep influence on the fantasy genre; although it was unknown for centuries and so not developed in medieval legend and romance, several fantasy works have retold the tale, such as John Gardner's Grendel.John Grant and John Clute, The Encyclopedia of Fantasy, "Beowulf", p 107

Norse

Norse mythology, as found in the Elder Edda and the Younger Edda, includes such figures as Odin and his fellow Aesir, and dwarves, elves, dragons, and giants.John Grant and John Clute, The Encyclopedia of Fantasy, "Nordic fantasy", p 691 These elements have been directly imported into various fantasy works, and have deeply influenced others, both on their own and through their influence on Nordic sagas, Romanticism, and early fantasy writers.

The Fornaldarsagas, literally tales of times past, or Legendary sagas, occasionally drew upon these older myths for fantastic elements. Such works as Grettis saga carried on that tradition; the heroes often embark on dangerous quests where they fight the forces of evil, dragons, witchkings, barrow-wights, and rescue fair maidens.John Grant and John Clute, The Encyclopedia of Fantasy, "Saga", p 831

More historical sagas, such as Völsunga saga and the Nibelungenlied, feature conflicts over thrones and dynasties that also reflect many motifs commonly found in epic fantasy.

The starting point of the fornaldarsagas' influence on the creation of the Fantasy genre is the publication, in 1825, of the most famous Swedish literary work Frithjof's saga, which was based on the Friðþjófs saga ins frœkna, and it became an instant success in England and Germany. It is said to have been translated twenty-two times into English, twenty times into German, and once at least into every European language, including modern Icelandic in 1866. Their influence on authors, such as J. R. R. Tolkien, William Morris and Poul Anderson and on the subsequent modern fantasy genre is considerable, and can perhaps not be overstated.

Celtic

Celtic folklore and legend has been an inspiration for many fantasy works. The separate folklore of Ireland, Wales, and Scotland has sometimes been used indiscriminately for "Celtic" fantasy, sometimes with great effect; other writers have distinguished to use a single source.John Grant and John Clute, The Encyclopedia of Fantasy, "Celtic fantasy", p 275

The Welsh tradition has been particularly influential, owing to its connection to King Arthur and its collection in a single work, the epic Mabinogion. One influential retelling of this was the fantasy work of Evangeline Walton: The Island of the Mighty, The Children of Llyr, The Song of Rhiannon, and Prince of Annwn. A notable amount of fiction has been written in the area of Celtic fantasy.Michael Moorcock, Wizardry & Wild Romance: A Study of Epic Fantasy p 101

The Irish Ulster Cycle and Fenian Cycle have also been plentifully mined for fantasy.

Scottish tradition is less used, perhaps because of the spurious nature of the Ossian cycle, a nineteenth-century fraud claiming to have much older sources.

Its greatest influence was, however, indirect. Celtic folklore and mythology provided a major source for the Arthurian cycle of chivalric romance: the Matter of Britain. Although the subject matter was heavily reworked by the authors, these romances developed marvels until they became independent of the original folklore and fictional, an important stage in the development of fantasy.Colin Manlove, Christian Fantasy: from 1200 to the Present p 12

Finnish

The Finnish epic, the Kalevala, although not published until the 19th century, is compiled from oral tradition dating back to an earlier period. J. R. R. Tolkien cited it, with the Finnish language he learned from it, as a major inspiration behind the Silmarillion.Tom Shippey, The Road to Middle-earth, p 242-243,

Renaissance

During the Renaissance, Giovanni Francesco Straparola wrote and published The Facetious Nights of Straparola, a collection of stories, many of which are literary fairy tales Giambattista Basile wrote and published the Pentamerone, a collection of literary fairy tales, the first collection of stories to contain solely the stories later to be known as fairy tales. Both of these works includes the oldest recorded form of many well-known (and more obscure) European fairy tales.Steven Swann Jones, The Fairy Tale: The Magic Mirror of Imagination, Twayne Publishers, New York, 1995, , p38 This was the beginning of a tradition that would both influence the fantasy genre and be incorporated in it, as many works of fairytale fantasy appear to this day.L. Sprague de Camp, Literary Swordsmen and Sorcerers: The Makers of Heroic Fantasy, p 11