Poetry as an art form may predate literacy. The earliest poetry is believed to have been recited or sung, employed as a way of remembering oral history, genealogy, and law. Poetry is often closely related to musical traditions, and the earliest poetry exists in the form of hymns (such as the work of Sumerian priestess Enheduanna). Many of the poems surviving from the ancient world are recorded prayers, or stories about religious subject matter, but they also include historical accounts, instructions for everyday activities, love songs, and fiction.
Many scholars, particularly those researching the Homeric tradition and the oral epics of the Balkans, suggest that early writing shows clear traces of older oral traditions, including the use of repeated phrases as building blocks in larger poetic units. A rhythmic and repetitious form would make a long story easier to remember and retell, before writing was available as an . Thus many ancient works, from the Vedas (1700 - 1200 BC) to the Odyssey (800 - 675 BC), appear to have been composed in poetic form to aid memorization and oral transmission, in prehistoric and ancient societies. Poetry appears among the earliest records of most literate cultures, with poetic fragments found on early monoliths, runestones and stelae.
The oldest surviving speculative fiction poem is the Tale of the Shipwrecked Sailor, written in Hieratic and ascribed a date around 2500 B.C.E. Other sources ascribe the earliest written poetry to the Epic of Gilgamesh written in cuneiform; however, it is most likely that The Tale of the Shipwrecked Sailor predates Gilgamesh by half a millennium. The oldest epic poetry besides the Epic of Gilgamesh are the Greek epics Iliad and Odyssey and the Indian Sanskrit epics Ramayana and Mahabharata. The longest epic poems ever written were the Mahabharata and the Tibetan Epic of King Gesar.