When Litwak’s Family Fun Center & Arcade closes at night, the various video-game characters leave their normal in-game roles and are free to travel to other games. Within the game Fix-It Felix, Jr., the characters celebrate its titular hero but ostracize the game’s villain character, Wreck-It Ralph. At a support group for video-game antagonists, Ralph reveals his desire to stop being the bad guy. Back home, Ralph finds the other characters celebrating their game’s 30th anniversary without inviting him. Felix reluctantly invites Ralph to join them, but the others isolate him. They tell him that if he won a medal, as Felix does in their game, they would respect him.
At Tapper’s, Ralph learns he can win a medal in the first-person shooter Hero’s Duty. Ralph enters the game and encounters Sergeant Calhoun, its leader. Between game sessions, Ralph climbs the game’s central beacon and collects the medal, accidentally hatching a Cy-Bug, one of the game’s enemies. It clings to Ralph as he stumbles into an escape pod that launches him out of the game. Meanwhile, with Ralph missing, a girl reports to arcade-owner Litwak that Fix-It Felix, Jr. is malfunctioning. Since broken games get unplugged, leaving their characters homeless, Felix searches for Ralph.
Ralph crash-lands in Sugar Rush, a kart-racing game. As he searches for his medal, he meets Vanellope von Schweetz, a glitchy character who takes the medal and uses it to buy entry into a race. King Candy and the other racers refuse to let Vanellope participate, claiming she is not really part of the game. Ralph helps Vanellope build a kart. At her home in Diet Cola Mountain, an unfinished racing course, he discovers she is a natural racer.