The giant spider in Peter Jackson’s The Lord of the Rings: The Return of the King is Shelob.
Shelob attacks Frodo and Sam in the pass of Cirith Ungol while they are trying to reach Mordor. Sam uses the sword Sting and the Phial of Galadriel to confront her after she stings Frodo and leaves him apparently dead.
In Tolkien’s mythology, Shelob is an ancient giant spider and a descendant of Ungoliant, a much older creature from the wider history of Middle-earth. Jackson’s film presents her as a major creature set piece near the end of the trilogy.
Shelob is sometimes confused with Ungoliant because of their shared spider-like nature and family connection. Ungoliant does not appear as a character in Jackson’s Lord of the Rings films; Shelob is the spider seen on screen.