A terrier named Max lives with his owner Katie in an apartment in Manhattan, the two being close companions. One day, Katie returns with a mongrel named Duke, and Max becomes envious of the attention Duke receives from Katie. A rivalry grows between the two pets, culminating in Duke attempting to abandon Max in an alley. However, the two are attacked by a gang of alley cats led by Ozone, and have their collars removed. The two are promptly caught by Animal Control.
Max's friend, a pomeranian named Gidget, sets out to find Max, teaming up with an hawk named Tiberius. Meanwhile, the van carrying Max and Duke is hijacked by a group of sewer-dwelling animals led by a rabbit named Snowball, who recruits Max and Duke to join him in his plan to exact revenge upon humans for disowning him and the other animals. Upon being exposed as pets, Max and Duke flee, accidentally killing Snowball's viper. Enraged, Snowball vows to kill them. Meanwhile, Gidget and Tiberius seek help from Max's friends, a cat named Chloe, a pug named Mel, a dachshund named Buddy, a budgerigar named Sweatpea, a guinea pig named Norman and a basset hound named Pops in order to find Max. However, they are attacked by Snowball's gang, who abducts Norman.
In Brooklyn, Max and Duke begin to befriend each other. While at a sausage factory, Duke confesses that he had an owner named Fred, but the two were separated. Max encourages Duke to return to Fred's house to reunite with him, but upon arriving, they find out that Fred passed away. The two are then confronted by Animal Control, who take Duke away. While attempting to rescue Duke, Max meets Snowball, whose comrades are also taken by Animal Control. Max and Snowball team up in order to rescue their friends, hijacking a bus and crashing it into the van on the Brooklyn Bridge, stopping traffic.
Snowball's gang corners Max on the bridge, but Gidget and her team arrive and save him. However, the van plummets into the East River with Max and Duke trapped inside. Snowball jumps into the river and retrieves the key to Duke's cage, allowing him and Max to escape the sinking van. The animals then take a taxi and return to the apartment, where they reunite with their respective owners while Snowball is adopted by a young girl. Meanwhile, Katie returns to the apartment, where she reunites with Max and Duke.