Samwise Gamgee is a hobbit, Frodo Baggins's gardener and his companion on his journey to Mount Doom. When Gandalf comes to the Shire to tell Frodo the truth about the ring he inherited from his uncle Bilbo, he catches Sam eavesdropping, and orders him to go with Frodo on his journey. They are joined en route to Rivendell by Meriadoc "Merry" Brandybuck and Peregrin "Pippin" Took, two of Frodo's cousins, and Strider, a Dúnedain ranger of the North. At Rivendell, Frodo volunteers to take the Ring to Mount Doom to destroy it, and Sam volunteers to go with him. They are joined by the other hobbits and Strider, now revealed as Aragorn, last heir to the throne of Gondor, along with Gandalf, Gimli the Dward, Legolas the Elf, and Boromir, a man from Gondor, elder son of the Steward, Denethor II.
Frodo ultimately decides that he must leave the Fellowship behind and continue on his own, but Sam insists on going with him. They soon capture Gollum and force him to act as their guide, though Sam is always suspicious of the wretched creature. His fears are later vindicated when Gollum leads Frodo into the lair of Shelob, a giant spider, hoping that Frodo will be killed and he could then take the Ring.
Sam saves Frodo from Shelob, but Frodo has been stung by Shelob, and it appears to Sam as if he is dead. Later, when Orcs approach, Sam takes the Ring, and intends to go on alone, and complete the mission given to Frodo. However, he overhears the Orcs talking and discovers that Frodo isn't dead, simply paralyzed by Shelob's poison. The Orcs take Frodo to the tower of Cirith Ungol on the western border of Mordor, Sam following all the way. Sam rescues Frodo from the Orcs and returns the Ring to him, and they travel toward Mount Doom once again.
Frodo grows progressively weaker under the influence of the Ring, and Sam's help is essential in getting him through Mordor to Mount Doom, once physically carrying him up the mountain until attacked by Gollum. There Frodo goes on alone, as Sam fends off Gollum. After seemingly defeating Gollum, he follows Frodo, urging him to throw the Ring into the fire, a scene shockingly similar to that which had happened 3000 years before, when Elrond told Isildur to destroy the Ring. Frodo decides to keep the Ring, and as he puts it on Sam is knocked out by Gollum, who then attacks Frodo, in a desperate fight to the death over possession of the ring. Sam watches the fight between them, until Frodo and Gollum topple over the precipice. Sam rescues Frodo, but Gollum and the ring perish in the volcano.
At the end, Sam returned to the Shire, and married the one that he loved, Rosie Cotton, and they had many children: Elanor (named after the flower in Lorien), Goldilocks, Frodo, Pippin, Merry, Hamfast, Rose, and others. He continued to look after Frodo, particularly on the two days of year where he always fell ill, the day on which the ring perished, and the day on which he was pierced by the Morgul blade, until Frodo left for Valinor. He always felt somewhat guilty for his fame in Hobbiton, for he, Merry, and Pippin were hailed as heroes for saving the Shire from the "Boss", "Sharkey" aka Saruman, who had taken over the Shire. He felt Frodo deserved fame much more than he, but Frodo liked the anonymity.
Sam was mayor of Hobbiton for many years. When Rosie died, he took a ship to Valinor (the Undying Lands), as he was himself a ring-bearer for a short while.