Beowulf dies during battle with a dragon. In the second part of the poem, Beowulf has ruled over the Geats for fifty years, and he is a good leader. When the dragon attacks, it is worthy of note that he does not do so unprovoked. The dragon has been tasked with guarding a treasure hoard, and although the original owner of the treasure has long since died, the dragon continues to stand guard. When a cup is stolen from the treasure by a man who wants to win favor with his master, the dragon seeks revenge on Beowulf's people. Beowulf takes a large retinue of warriors to fight the dragon, but at the sight of the creature, all of Beowulf's vassals flee with the exception of Wiglaf, the youngest. Beowulf and Wiglaf fight the dragon together, and although they kill the dragon, Beowulf is fatally wounded. As he lays dying, Beowulf gives Wiglaf instructions for his burial and the disposal of the treasure.
Wiglaf's remaining by Beowulf's side reinforces the theme of loyalty in the poem. Beowulf is ultimately faithful to his lord, Hygelac, even while he is fighting in the service of Hrothgar, a rival lord. This loyalty is repaid when Wiglaf remains by his side, even while his other vassals flee.