It could be claimed – unprovably – that the ancient Egyptians were the first to write fantasy. Certainly Egypt offers the oldest known examples of the Fairytale, the prose short story and several narrative devices. Both fanciful and realistic stories were written as early as the 20th century BC; the writers of the former may well have seen a difference and so known themselves as fantasists. There is no such possibility in any other of the world's literatures until centuries later.
Native Egyptian rule ended in 525BC, and the country thereafter produced Greek, Jewish, Christian and Muslim works of the first importance. Here we are concerned solely with the two Egyptian literatures prior to Egypt's conversion to Christianity, which created significant literary discontinuities. The first strand produced narratives circa 1950-circa 1050BC; the narratives of the second were written 500BC-AD300. Neither is at all well known, nor is it clear how much connection there is between them. Most Egyptian stories have been found in only one papyrus or inscription, anonymous and datable only by that copy's date, not the (possibly much earlier) date of composition. Many are fragmentary or incomplete – including every story yet found from the later period. A full collection in translation would run to only a few hundred pages. Many of the most important works can be found in Miriam Lichtheim's excellent Ancient Egyptian Literature (anth 1973-1980 3 vols).
Quite realistic, quasi-religious autobiographies inscribed in tombs or on stone are the oldest narratives, beginning about 2300BC. In the 20th century BC an older genre of wisdom literature diversified and acquired narrative frames or fully narrative form. In contrast, the story of Sinuhe transfigured the autobiographic genre. A powerful realistic tale of exile and forgiveness, it includes examples of several other literary genres in an artful structure which well disguises its likely propagandistic purpose. It was often copied until the 13th century BC. Other fantasies of that period seem artless by comparison, but show from the beginning a grasp of the basic technique of story-within-story (see Frame Story); they do not obviously derive from any older genre. In "The Shipwrecked Sailor" (20th century BC) the title character appealingly and didactically relates his rescue and enrichment by a regal, kindly Dragon (who in turn has a story to teach). Papyrus Westcar (circa 1600BC) gives the oldest examples of stories about magicians.
In the subsequent centuries of empire, many fantastic stories appeared. Those known include a charming Ghost Story, an Allegory with fairytale elements; and the wildly bombastic Kadesh inscriptions (1270BC), in which Rameses II claims to have slain hundreds of thousands in a day's battle, single-handed. Meanwhile "The Doomed Prince" (circa 1300BC) is the oldest known fairytale. It remoulds "Sinuhe", breaking from autobiography into the third person, to depict an exile fleeing fates which prove to be Talking Animals. "The Two Brothers" (circa 1200BC), perhaps by Ennana, is among the greatest works of these centuries. From a mundane opening it becomes a rich fairytale, then moves to transformation and apotheosis. A number of Myths also survive from this era. "The Contendings of Horus and Seth" (circa 1145BC), a farcical tale of the last phase of the great Osiris cycle, crude in both style and content, is the earliest known example of myth-Parody. Both it and "The Two Brothers" contain several motifs later found in the Bible.
Very little narrative at all survives from 1050-1550BC. The only relevant example is a fragment from a student's slate (before 730BC) which tells of a lawsuit between the belly and the head for primacy over the body. This is arguably a Fable, the oldest written one known, though Egyptian art and Mesopotamian literature allude to fables much earlier.
In the later narratives, mostly written in the newer Demotic script, wild fairytales and sober realism both vanished in favour of Romances, sometimes fantastic, sometimes not. The change is already apparent in the Underworld story of the magician Merire (circa 500BC; ed and trans into French by Georges Posener as Le Papyrus Vandier 1986) and the fragmentary texts from Saqqara (4th century BC; ed and trans H S Smith and W J Tait as Saqqara Demotic papyri 1 1983), which involve the Gods more than most later romances. Saqqara Text 1 seems very like a secular romance of separated lovers' adventures such as later became popular in Greek (see Greek and Latin Classics).
The best-preserved Demotic romances (as well as many of the fragments) fall into two cycles. There are martial ones, generally without fantastic elements, about the heirs of Inaros; and there are two tales of a magician called Setna. Setna 2 (2nd century AD) includes an underworld tour and a magician's duel across millennia. Setna 1 (1st century BC) concentratedly and with some eloquence contrasts Setna's lust and wrongdoing with ancient mages' true love and suffering; several copies are known.
None of the later works, save presumably the Beast Fables now found in numbers, were necessarily written as fantasy; Egypt was then, after all, a centre of magical study. Contemporaneous myths in Egyptian often seem like sacred dramas, as such constituting the only genre with any resemblance to the last masterpiece known to us: the "Kufi text" (2nd century AD). This tells of the Goddess Kufi's angry departure from Egypt and Thoth's efforts to persuade her to return. In this cause Thoth mixes rank flattery, drawing on the language of hymnody, with moralizing built from both wisdom traditions and fables; the goddess forces him to tell many of the latter, of which three are intact. The whole melds multiple genres at the end of ancient Egyptian literature as skilfully as did "Sinuhe" at its start, with the addition of Humour, and was often copied and even translated into Greek before Egypt's Christian conversion in the 3rd and 4th centuries submerged the native tradition. [JB]
further reading: Relevant essays in Civilizations of the Ancient Near East (1955) ed Jack M Sasson; "Egyptian Fiction in Demotic and Greek" by John Tait in Greek Fiction (1994) ed J R Morgan and Richard Stoneman.