As Andy, now 17, prepares to leave for college, Woody, Buzz, and the rest of Andy's toys face an uncertain future, since Andy hasn't played with them in years. Deciding to take Woody to college, Andy packs the others in a garbage bag, intending to store them in the attic. Unfortunately, as Woody watches, Andy's sister distracts him and his mom puts the garbage bag outside, mistakenly thinking it contains trash.
Believing that Andy no longer wants them, the toys escape from the bag and sneak into a box in Andy's mom's car to be donated to Sunnyside Daycare. Woody finds the others and tries to explain, but they refuse to listen and Woody is forced to go with them to Sunnyside. Once there, Andy's toys receive a warm welcome from the Sunnyside toys, led by Lots-O'-Huggin' Bear, aka Lotso. Woody tries to convince the others to return with him to Andy, but they decide they're happier at Sunnyside. Reluctantly, Woody leaves alone, only to be found by Bonnie, a girl from the center, and taken home to become one of her toys.
Woody's friends soon discover that the children Lotso assigned them to be played with are hyperactive toddlers, who abuse and torture them. When Buzz goes to ask Lotso to assign them to an older group of kids so they won't be abused as much, he discovers that Lotso is running Sunnyside with an iron fist. Before Buzz can warn the others, Lotso catches him and resets him into his factory default, delusional astronaut self, erasing his memory of the others. Meanwhile, at Bonnie's house, Woody learns how Lotso was actually a nice, loving toy once, but when his owner lost and eventually replaced him, he snapped, ran away and took over Sunnyside, turning it into a toy prison camp.
Back at Sunnyside, the others discover that Andy is looking for them when Mrs. Potato Head sees him through her missing eye, which was lost in Andy's room. Realizing their error, the toys try to leave but Lotso and his henchmen -- which now includes the reset Buzz -- capture them.
The next day, Woody returns to Sunnyside to help his friends break out and return to Andy's house. They get out through a garbage chute, but Lotso and his henchmen catch them on a dumpster at the end of the chute. Woody and his friends convince Lotso's henchmen of Lotso's treachery, and they throw Lotso in the dumpster. Lotso, however, grabs Woody and pulls him in the dumpster just before a garbage truck collects its contents, forcing the others to jump in to rescue him. The truck takes them to a landfill, where the toys are dumped onto a conveyor belt leading to an incinerator. Woody saves the others, including Lotso, but Lotso leaves them to their fate instead of returning the favor. Just before they meet their certain doom, the toys are rescued by a giant claw crane operated by the squeeze toy aliens, while Lotso is found by a garbage man and tied to the front of a truck, to his dismay.
Woody, Buzz (who regained his memory in the escape) and the others return to Andy's house, and the toys, minus Woody, climb into the box to be stored in the attic. Deciding that his friends deserve better, Woody leaves a note on the box, then climbs into the box. Andy reads the note and decides to donate the toys to Bonnie. He pulls out each of his old toys one at a time and describes them, after which he and Bonnie play with them before he leaves. As Andy leaves, Woody introduces his friends to Bonnie's toys, while the Sunnyside toys begin turning the daycare center into a true toy paradise.