The sources of Hamlet, Prince of Denmark, a tragedy by William Shakespeare believed to have been written between 1599 and 1601, trace back as far as pre-13th century. The generic "hero-as-fool" story is so old and is expressed in the literature of so many cultures that scholars have hypothesized that it may be Indo-European in origin. A Scandinavian version of the story of Hamlet (called Amleth or Amlóði, which means "mad" or "not sane" in Old Norse) was put into writing around 1200 AD by Danish historian Saxo Grammaticus in his work Gesta Danorum (the first full history of Denmark). It is from this work that Shakespeare borrowed to create Hamlet. Similar accounts are found in the Icelandic Saga of Hrolf Kraki and the Roman legend of Lucius Junius Brutus, both of which feature heroes who pretend to be insane in order to get revenge. A reasonably accurate version of Saxo's story was translated into French in 1570 by François de Belleforest in his Histoires Tragiques. Belleforest embellished Saxo's text substantially, almost doubling its length, and introduced the hero's melancholy.
After this point, the ancestry of Shakespeare's version of Hamlet becomes more difficult to trace. Many literary scholars believe that Shakespeare's main source was an earlier play—now lost—known today as the Ur-Hamlet. Possibly written by Thomas Kyd, the Ur-Hamlet would have been in performance by 1589 and was seemingly the first to include a ghost in the story. Using the few comments available from theatre-enthusiasts at the time, scholars have attempted to trace exactly where the Ur-Hamlet might have ended and the play popular today begins. A few scholars have suggested that the Ur-Hamlet is an early draft of Shakespeare's, rather than the work of Kyd. Regardless of the mysteries surrounding the Ur-Hamlet, though, several elements of the story changed. Unlike earlier versions, Shakespeare's Hamlet does not feature an omniscient narrator of events and Prince Hamlet does not appear to have a complete plan of action. The play's setting in Elsinore also differs from legendary versions.