Hamlet, tragedy in five acts by William Shakespeare, written about 1599–1601 and published in a quarto edition in 1603 from an unauthorized text. Often considered the greatest drama of all time, the play tells the story of the troubled titular prince of Denmark.