Andy is now 17 years old and packing for college, and his toys who have not been played with in several years feel like they have been abandoned. Andy decides to take Woody with him to college and puts the rest of the toys in a trash bag for storage in the attic. However, the toys are accidentally thrown out when Andy’s mom finds the bag and puts it out on the curb, causing the toys to think they are no longer wanted. They escape and decide to climb in a donation box for the Sunnyside Daycare. Woody, the only toy who saw what actually happened, follows the other toys and tries to explain they were thrown out by mistake, but they refuse to listen.
Andy’s toys are welcomed by the many toys at Sunnyside and given a tour of the seemingly perfect play-setting by Lots-O’-Huggin’ Bear (known as Lotso), Big Babyand Ken, who Barbie falls for. All of the toys immediately love their new home, leaving a steadfast Woody alone in an attempt to return to Andy. However, Woody’s escape attempt fails and he is found outside by Bonnie, an imaginative little girl. She takes him home and plays with him along with her other toys, who are well-treated, happy, and readily welcome Woody. Woody is relieved until he hears about Lotso from Chuckles the sad clown. Lotso, along with Big Baby and Chuckles, were once accidentally lost by their original owner, Daisy. The three found their way back to Daisy’s home, but Lotso saw that he had been replaced with a similar toy bear. Though Chuckles realized the truth, Lotso, embittered, convinced Big Baby that they were all replaced, and took over Sunnyside, making it look like a prison at night. Worried for his friends, Woody hurries back to the daycare to find that they have been confined to the room with by the rambunctious youngest toddlers. They are also kept under guard at night by Buzz when Lotso had him reverted to demonstration mode, which restored his original “Space Ranger” persona.
Woody rejoins his friends and they stage an escape plan. In the process, Buzz is accidentally reset into a flamenco-dancing Spanish-speaking mode, but Buzz allies himself with Woody’s friends. The toys reach a dumpster but are caught by Lotso and his gang. As a garbage truck approaches, Woody reveals what he heard about Lotso, leading Big Baby to toss him in the dumpster. Seeking revenge, Lotso pulls Woody in with him just as the garbage truck collects the garbage. Woody’s friends board the truck to rescue him. A falling television hits Buzz when he tries to save Jessie, finally returning to his normal self. The toys find themselves at the dump and are pushed onto a conveyor belt leading to a trash crusher. Woody and Buzz save Lotso just in time as he is about to be crushed. Woody and the other toys are then pushed onto another conveyor belt leading to an incinerator. They help Lotso reach an emergency stop button, but he leaves them to their deaths. Thinking that this is the end, the toys grasp each other’s hands. The toys are eventually rescued by the squeeze toy aliens using a giant claw. Lotso makes his way outside, but a passing truck driver finds Lotso and straps him to the radiator grille of his truck–a fitting comeuppance. Meanwhile, Woody and his friends board a neighborhood trash truck back to Andy’s house.
In Andy’s room, Woody climbs back into the box with Andy’s college supplies while the other toys ready themselves for the attic. Remembering his time with Bonnie and her toys, Woody has an idea and leaves a note for Andy on the toys’ box. Andy, taking it for a note from his mom, takes the box to Bonnie’s home, introduces his old toys to Bonnie and gives her the toys to play with. In the end, Bonnie recognizes Woody, who, to Andy’s surprise, is lying at the bottom of the box. Andy is initially reluctant to give him up to her but he eventually does so and then spends some time playing with her before he departs. Woody and the other toys find themselves wanted and played with again and learn through notes passed in Bonnie’s backpack that Barbie, Ken, and Big Baby have improved the lives of all the toys at Sunnyside.