Shakespeare's most famous last words are "Good night, sweet prince, and flights of angels sing thee to thy rest." These words are spoken by Horatio, a close friend of Hamlet, in the final scene of the play Hamlet.
While this is the most famous line from the play, it is not technically Hamlet's last words. The last words spoken by Hamlet in the play are "O, I die, Horatio, and if thou didst ever hold me in thy heart, Absent thee from felicity awhile, and in this harsh world draw thy breath in pain, To tell my story."
These words are often overlooked because of the emotional weight of Horatio's line. However, they are significant because they reveal Hamlet's final thoughts about the world and his desire for Horatio to tell his story.
Although these lines are attributed to Hamlet, it's important to note that Shakespeare himself never revealed his own last words. There are many theories about what he might have said, but no definitive answer exists.