Set in the fictional town of Oakton, year 1959, a group of animals, led by a Raccoon, store food for winter in a giant tree in the park. Among these animals is a selfish purple squirrel named Surly, whose thieving reputation has made him a pariah. His only friend is his rat partner Buddy. Surley's attempt to rob a peanut cart goes haywire when it is impeded by one of Raccoon's helpers, a compassionate orange squirrel named Andie and the 'park hero', a grey squirrel named Grayson whose heroic antics prove to be incompetent. After Andie unsuccessfully tries to talk Surly into being more selfless, Surly tries to get a bag of nuts while the owner gets distracted by a bratty girl scout customer and a police officer - but this heist also gets invaded by the pet pug of the owner of the cart named Precious. After fending off Precious by having her bite the pipe of a liquid nitrogen tank, Surly and Buddy escape with the cart and Andie manages to guide it to the park. Surly threatens Andie and Grayson with a torch, unwilling to share the food, but accidentally causes it to ricochet across the park. Although the animals (except for Grayson) get off safely, the cart is sent into the tree, where it explodes-- along with the tree and the animals' food supply. When Surly is identified as the culprit, Raccoon banishes Surley from the park, forcing the squirrel to survive in the city.
Although Buddy insists on being with Surly, Surly insists that Buddy leave him. After escaping from wild street rats, Surly and Buddy find a nut store and attempt to rob it to feed themselves. After entering the store, they discover that it's a criminal hideout, used by the cart owner, his associate, their mob boss King who has recently gotten out of jail, and fellow felon, Fingers. Raccoon sends Andie and Grayson to find food only for them to get separated upon Grayson fighting a rat. Precious also serves as the guard dog there. King plans to rob the Oaken Bank and replace the cash with nuts. Surley and Buddy see that the only way to get to the nuts and to avoid Precious is with a dog whistle one of the crooks has. The two of them are thrown out by Fingers since he can hear it. While trying to find the whistle, Surly crosses paths with Andie who gets the whistle and threatens to dispose of it if Surly doesn't share the food he's going to take. Reluctantly, Surly accepts and unwittingly befriends Precious after threatening her with the whistle. Andie informs the park of the plan and, although they have a lack of faith in Surly, they agree to go along with it. Andie gets help from the Bruisers, a family of Groundhogs consisting of Jimmy, Johnny, and Jamie. Also with them is Raccoon's mole henchman.
When the first attempt to rob the store fails, Surly eventually learns from Andie that Raccoon planned on double crossing him and Surley leaves after an argument. Back at the park, Raccoon's true colors are revealed, a power hungry con artist who keeps food from the animals to have his leadership kept and only Mole and his Cardinal assistant know about it. He sends out Mole to sabotage the the next attempt at robbing the store by flooding the tunnels the Bruisers have dug, but Surly (after meeting up with Grayson) finds out and saves the passed out Bruisers. Precious catches Mole and he reveals Raccoon's intentions. He attempts to warn the others, but they don't believe him and after tensions rise, they part ways (with Buddy joining the animals after Surly hurts his feelings). Surly is captured by the criminals, but is let out by King's girlfriend Lana whose upset to find out that her beau is making another heist and leaves with Precious. After Surly tries to leave to with his share, he is captured by the street rats who are revealed to be working for Raccoon. After Raccoon reveals that his plan involves hurting his friends, Surly manages to escape and heads down to the store's basement to save them. He tells to Grayson to get the team to safety distracts King long enough for his friends to escape with food for King's heist. The animals (minus Grayson) meet up with Raccoon, who lies about Surly committing treachery.
Raccoon eventually locks them up in a get away van used by the robbers. Surly and Grayson use pigeons to catch up and save the others. After defeating the Cardinal, the robbers find out that King double crossed them by filling up their truck with nuts instead of money. After Grayson and Surly open the door to release their friends, Raccoon appears and tries to get the others to throw Surly off, but a redeemed Mole reveals that Raccoon is the true traitor and the animals turn on him. After the animals evacuate the truck (minus Raccoon and Andie), the get away cars head down to a bridge where the police are waiting to detain the criminals. King and Fingers try to use dynamite to blow the police out, but the truck hangs over the bridge. Surly gets Andie off the truck as the dynamite goes off inside the truck and as it (along King and Raccoon, who are still inside it) falls down into the river, but he eventually falls down into it himself. Surly makes it to a log, but Raccoon reveals to have survived the explosion (along with King). Raccoon tries to kill Surly, but the nuts make weight that begins to break the log. The animals arrive to rescue them, but Raccoon won't give up. So Surley, deciding to be selfless in order to protect his friends, sacrifices himself by letting go of the log and going over the waterfall, killing Raccoon and Surly apparently. The animals, now seeing the good side of Surly, mourn him in honor of the most selfless act he committed in years.
The food makes its way into the park, where the animals gather around in joy for their food troubles are over. King is arrested as Lana appears to end their relationship. Andie and Buddy are still mourning over Surly and when Precious finds out what happened to her friend, she eventually finds Surly's apparent dead body near the river. She has Buddy come and look at it. Doleful to see his best friend gone, Buddy says his first 2 words (best friend). Surly reveals that he was actually unconscious and hugs Buddy and Precious licks Surly's face (which she wanted to do since she got involved in Surley's heist) and leaves to Lana. Finding that Surly is alright, Andie embraces him and tries to get him to come to the other animals so he can tell of his heroism, but Surly, feeling as though it was the other animals that were the true heroes, refuses, but gains a willingness to work with others. He goes along to the city, possibly to pull off another caper, with Buddy joining him.
During the credits, the animals dance with PSY as he performs "Gangnam Style."