As Andy, now 17, prepares to leave for college, his toys face an uncertain future, since he hasn’t played with them in years. He decides to take Woody with him, packing the others in an unlabeled garbage bag, which he intends to store in the attic. Unfortunately, when Andy’s sister distracts him, his mom takes the garbage bag to the curb, thinking that it contains trash.
Woody, the only toy who realizes what Andy was trying to do, finds the others and tries to explain, but they refuse to listen. They decide instead to go to a daycare center, and Woody winds up unintentionally going with them. Upon their arrival, they receive a warm reception from the other toys, led by a large stuffed bear (Lots-o-Huggin’ Bear, aka "Lotso"). Seeing how happy his friends are at the center, Woody says goodbye to them and leaves for Andy’s house. He doesn’t get far before Bonnie, one of the center’s kids, finds him and takes him home to become one of her toys.
Meanwhile, Woody’s friends receive an unpleasant surprise when the group of young kids in the room where they are located plays with them too roughly. They then learn that Woody was telling the truth when Mrs. Potato Head, who lost an eye in Andy’s house, sees Andy becoming upset with his mom over the toys; they decide to escape. Buzz leaves the room, but before he can help the others, Lotso catches him and tries to bargain with him. Buzz refuses, and Lotso reprograms him, then turns him on the others, thus imprisoning them.
At Bonnie’s house, Woody learns that Lotso was once owned by a loving girl named Daisy, but snapped when he discovered that he was replaced after being lost during a family trip: Daisy had fallen asleep. Lotso then took over the daycare center, making it a prison for its toy inhabitants. Woody decides to rescue the others from the daycare center and get back to Andy’s house before Andy departs for college.
Woody sneaks in and comes up with a plan to bypass the security that Lotso has set up. He and his friends reprogram Buzz, but during the process, he loses his memory, behaving like a real Space Ranger while speaking spanish. The toys nearly escape, but Lotso catches them on a dumpster, with a garbage truck fast approaching. Woody convinces the other daycare toys of Lotso’s treachery, and they toss Lotso in the dumpster. However, Lotso grabs Woody at the last minute, and Woody’s friends jump in to rescue him. The garbage truck then takes them all to the city dump, where Woody rescues his friends — and Lotso — from an incinerator. Lotso, however, betrays them and leaves them to certain death, only to be rescued by the green aliens, who separated from the gang, and meanwhile discovered an oversize version of a familiar tool. Eventually, Lotso is snatched by a garbage man who once had a Lotso of his own: he is tied to the front of the garbage truck, along with a few other mangled toys, who immediately dispense friendly advice to their fellow passenger.
Meanwhile, having narrowly escaped the incinerator, Woody and the gang clean themselves up and make their way back to Andy’s house. Woody decides that his friends deserve better than being stored in the attic, and leaves a sticky note on their box. Andy reads the note and donates the toys to Bonnie, introducing each toy. Bonnie notices Woody at the bottom of the box. Hesitant to give him up at first, Andy realizes that Bonnie will take good care of Woody, adding he is "special because he’ll never give up on you … no matter what," as he hands her the cowboy. Andy and Bonnie play with the toys before Andy finally drives off. As Woody and Buzz watch Andy leave, Woody introduces Buzz and his friends to Bonnie’s other toys.
The ending credits show Andy’s toys getting used to life at Bonnie’s, while Sunnyside is now a happy place for new arrivals as well as old toys.