The entire text is consumed with the search of Gilgamesh for immortality. He is a larger than life character who is obsessed with not dying, and who endangers his own life happily in the hope of gaining immortality. In the end, Gilgamesh is a character who does not gain immortality but learns wisdom, and part of the wisdom that he learns is the acceptance of mortality, but this is a lesson that is hard to learn and it is one that Gilgamesh has to personally confront when his friend and erstwhile sidekick, Enkidu, dies. Note how Gilgamesh grieves his friend's death:
The paths going up to and down from the forest of cedars
All mourn you: the weeping does not end day or night.
Gilgamesh has to realise that all men, including himself, die at some point in their lives, and that the only response in the face of such mortality is to live life as happily and merrily as one is able to, as he learns from Siduri, the goddess of wine-making. The tragedy of mortality is thus expressed in the way that Gilgamesh sets out at the beginning of this epic classic to gain immortality but is forced to confront the mortality of man through the death of his best friend and his own mortality, moving towards an acceptance of his own state as a thoroughly mortal being.