Saxo Grammaticus ("Saxo the Literate", literally "the Grammarian") publishes his Gesta Danorum ("Deeds of the Danes"), a work of Danish history that includes Vita Amlethi ("The Life of Amleth") which interweaves several older legends into a tale that bears, for the first time, some resemblance to Shakespeare's Hamlet including a king murdered by his brother, a prince that feigns madness, his queen mother's hasty marriage to the usurper, the prince killing a spy hidden in his mother's chamber, and the alteration of a letter by the prince in order to substitute the execution of two retainers for his own. However, the story also differs significantly from Shakespeare's version. Grammaticus' Amleth achieves revenge without sacrificing his own life, becomes King of Denmark, marries the Queen of Scotland, and finally dies in battle. 
A reasonably faithful version of Saxo's story is translated into French in 1570 by François de Belleforest in his Histoires Tragiques. Belleforest embellishes Saxo's text substantially, almost doubling its length and introducing for the first time the ghost of the murdered king who is referenced by his son (now called "Hamblet") in two scenes -- the interview with his mother and the scene in which he murders the usurper.   Writing of the first of these references, Arthur P. Stabler notes: "The principle significance of the passage, however, lies ... in the light which it casts on the motivation of Hamlet himself. In the Belleforest story, as in the Shakespeare play, the scene in question is among the most important ones. In both versions, Hamlet, reinforcing his efforts to operate a change in his mother's spirit, deliberately calls up before her consciousness the image of her murdered husband. In this preoccupation with the memory of his father, revealed for the first time in this passage from Belleforest, and much more explicitly stated in the corresponding scene (and elsewhere) in Shakespeare, Hamlet shows that he considers himself to be acting on behalf of his father."  The first known English translation of Belleforest's embellishments did not appear until 1608, making it likely that this version of the Hamlet account was available to Shakespeare only in French. 
In his introduction to Robert Greene's Menaphon, Thomas Nashe refers to a play of uncertain authorship involving the character of Hamlet:
English Seneca read by candle-light yields many good sentences, as Blood is a begger, and so forth; and if you entreat him fair in a frosty morning, he will afford you whole Hamlets, I should say handfuls of tragical speeches.
This play, which has come to be called the Ur-Hamlet (the German prefix Ur- means "primordial") is considered by most historians to be a precursor to Shakespeare's Hamlet rather than an early draft of the same play, and authorship is most often ascribed to Thomas Kyd whom Nashe alludes to in the same passage. Because of this and a later reference by Thomas Lodge, this play is considered the first version of the story to incorporate the ghost as an active character. However, since no copy of the Ur-Hamlet has survived, it is impossible to determine with any certainty how much material Shakespeare borrowed from this earlier play. As one critic writes:
Of the Ur-Hamlet all that can be said is that it was presumably Shakespeare's direct source and probably contained what is common to Shakespeare and Belleforest. Kyd, or his imitator, may have contributed some details of plot to Shakespeare's version, the 'play-within-the-play' or the fencing match for example, and he perhaps introduced the ghost into the action, though Lodge's allusion -- "as pale as the Visard of ye ghost which cried so miserably at ye Theator, like an oister wife, Hamlet, revenge" -- leaves the matter in doubt. The ghost perhaps appeared only in the prologue and not in the action: certainly, the three allusions to it which survive suggest that it was Senecan in the worst sense. 
In his preface to Sidney's Astrophel and Stella, Thomas Nashe writes:
...nor hath my prose any skill to imitate the Almond leape verse, or sit tabring five years together nothing but 'to bee, to bee,' on a paper drum.
Some critics have interpreted this as a reference to an early version of Hamlet's "To be or not to be" soliloquy. 
A performance of a play called Hamlet is recorded in Philip Henslowe's diary on June 9, 1594. He did not mark it "new" as he generally did on the occasion of a first performance. Although the play was produced at the Newington Butts theatre by the Lord Chamberlain's Men (Shakespeare's company), it is usually presumed to have been a performance of the Ur-Hamlet rather than Shakespeare's play. 
Gabriel Harvey ascribes the authorship of Hamlet To Shakespeare writing:
The younger sort take much delight in Shakespeare's "Venus and Adonis," but his "Lucrece" and his tragedy of "Hamlet, Prince of Denmark," have it in them to please the wiser sort."
This note was inscribed in a copy of Speght's Chaucer, owned by Harvey, with the date 1598 appended to the entry. However, some historians have questioned the validity of this date. 
An entry of 26 July 1602 in the Register of the Stationers' Company indicates that Hamlet was "latelie Acted by the Lo: Chamberleyne his servantes".  Most scholars date the first performance sometime during the previous year.
The booksellers Nicholas Ling and John Trundell publish, and Valentine Simmes prints the so-called "bad" first quarto of Hamlet. Q1 contains just over half of the text of the later second quarto. It is believed by some critics that the quarto of 1603 is merely an imperfect report of the play as we find it in the edition of the year after; but there are some material differences which cannot thus be explained. In the earlier quarto, instead of Polonius and Reynaldo, we find the names Corambis and Montano; the order of certain scenes varies from that of the later quarto; the madness of Hamlet is much more pronounced, and the Queen's innocence of her husband's murder much more explicitly stated. We are forced to believe either that Q1 contains portions of the Ur-Hamlet or that it represents imperfectly Shakespeare's first draft of the play or that the differences between it and the second quarto are due to Shakespeare's revision of his own work. 
The second quarto of Hamlet is published by Nicholas Ling -- "newly imprinted, and enlarged to almost as much againe as it was according to the true and perfect coppie." Q2 is the longest early edition, although it omits 85 lines found in the First Folio including the reference to Denmark being a prison (most likely to avoid offending James I's queen, Anne of Denmark). Some copies are dated 1605, which may indicate a second impression.  
Edward Blount and William and Isaac Jaggard publish the First Folio of Shakespeare's Complete Works. The First Folio edition of Hamlet contains 85 lines not in the Second Quarto, and omits 218 lines that are in it.  It is believed by some historians to have been printed from a transcript of a fair copy prepared from Shakespeare’s foul papers that contained his latest revisions, possibly intended for use as a promptbook or in preparation for performances at Oxford and Cambridge. 
- Looking for Hamlet. Marvin W. Hunt. New York: Palgrave Macmillan, 2007.
- Murder Most Foul: Hamlet Through the Ages. David Bevington. Oxford: Oxford University Press, 2011.
- "King Hamlet's Ghost in Belleforest." Arthur P. Stabler. PMLA. Voll. 77, No. 1 (Mar., 1962), pp. 18-20.
- Biblical References in Shakespeare's Plays. Naseeb Shaheen. London: Associated University Presses, 1999.
- The School of Shakespeare. David L. Frost. Cambridge: Cambridge University Press, 1968.
- Francis Bacon Our Shakespeare. Edwin Reed. Boston: Charles E. Goodspeed, 1902.
- The Life of Shakespeare. Daniel Webster Wilder. Boston: Little, Brown, and Company, 1893.
- Shakespeare. Edward Dowden. London: Macmillan & Co., 1879.
- The Oxford Handbook of Shakespeare. Ed. Arthur F. Kinney. Oxford: Oxford University Press, 2012.
- Hamlet, Prince of Denmark. Ed Brian Gibbons. Cambridge: Cambridge University Press, 1985.
- The Heart of Hamlet. Bernard Grebanier. New York: Thomas Y. Crowell Company, 1960.
- A Synoptic Hamlet. Jesús Tronch-Pérez. Valencia: Universitat de Valencia, 2002.