17-year-old Andy is about to leave for college, and his toys have not been played with for years. He intends to take only Woody with him, and puts Buzz Lightyear, Jessie and the other toys in a bag to be stored in the attic. Andy’s mother mistakenly takes the bag to the curb for garbage pickup. The toys escape and, believing Andy intended to throw them away, decide to climb into a donation box with Barbie bound for Sunnyside Daycare. Woody follows them but is unable to convince them of the mistake.
Andy’s toys are welcomed by the other toys at Sunnyside, and are given a tour of the seemingly idyllic play-setting by Lots-O’-Huggin’ Bear (“Lotso”), Big Baby, and Ken, with whom Barbie falls in love. The toys choose to stay, except Woody, who attempts to return to Andy, but is instead found by Bonnie, one of the Sunnyside students. She takes Woody home and plays with him along with her other toys, which are well-treated. Meanwhile, at Sunnyside, a group of toddlers play roughly with Andy’s toys, unlike the gentler older children.
Buzz seeks out Lotso to request to have them moved to the older children’s room, but Lotso, who controls Sunnyside in a concentration camp-like style, refuses, explaining that the newer toys need to be sacrificed to the younger children to protect the older ones, who want to avoid enduring such damage and suffering. Seeing promise in Buzz, he resets him to his original space ranger persona, which also resets his memory. At the same time, Mrs. Potato Head, through an eye she accidentally left in Andy’s room, sees Andy searching for the toys and realizes Woody was telling the truth. However, before they can leave, Andy’s toys are imprisoned by Lotso’s gang, guarded by Buzz.
At Bonnie’s house, a toy clown named Chuckles explains to Woody that he, Lotso and Big Baby once had a beloved owner named Daisy. When the toys were accidentally left behind by Daisy’s family during a trip, they made their way back to her house, only to find that Lotso had been replaced, causing Lotso to become resentful.
Woody returns to Sunnyside and learns from a Chatter Telephone toy that there is only one way out of the daycare: the trash. He reconciles with Andy’s other toys and begins planning a way out of Sunnyside. That night, the toys execute their escape, but accidentally reset Buzz to Spanish mode instead of his old persona. Buzz promptly allies himself with Woody and falls in love with Jessie. The toys reach a dumpster, but are caught by Lotso and his gang. As a garbage truck approaches, Woody reveals what he learned about Lotso and tosses Daisy’s ownership tag, which Chuckles had kept, to Big Baby. Lotso smashes the tag and says that toys are meant to be discarded, but this leads an enraged Big Baby to throw Lotso into the dumpster. As the toys try to run away, Lotso pulls Woody into the dumpster just as the truck collects the trash. The rest of Andy’s toys fall into the back of the truck while trying to rescue him, and a falling television lands on Buzz, restoring his memory and normal personality.
The truck deposits the toys at a landfill, where they find themselves on a conveyor belt leading to a shredder, and then an incinerator. Woody and Buzz help Lotso reach an emergency stop button, only for Lotso to abandon them and escape. The toys resign themselves to their fate, but are soon rescued by the Aliens operating an industrial claw. Lotso is found by a garbage truck driver who straps him to his truck’s radiator grill and drives away. Woody and his friends board another garbage truck back to Andy’s house.
In Andy’s room, Woody climbs into the box with Andy’s college supplies, while the other toys ready themselves for the attic. Woody leaves a note for Andy, who, thinking the note is from his mother, takes the toys to Bonnie’s house and introduces her to them. Bonnie recognizes Woody, who, to Andy’s surprise, is at the bottom of the box. Though hesitant at first, Andy passes Woody on to Bonnie, and then plays with her before leaving. Woody and the other toys watch Andy’s departure as they begin their new lives with Bonnie. Meanwhile, Barbie, Ken and Big Baby have made vast improvements to Sunnyside, and maintain contact with Woody and his friends through letters.