At the Central Park Zoo, Alex the lion, Marty the zebra, Gloria the hippo, Melman the giraffe, and the other animals prepare for another day of visitors while the Penguins (including Kowalski, Skipper, Private, and Rico) plan their escape. Zookeeper Zoe, Zookeeper Zeke, Zookeeper Zelda, and the other Zookeepers rev up the Zoo Guests. ("It’s Showtime"). Marty, feeling down about being trapped in the zoo, daydreams about what life would be like on the outside ("Wild And Free"). The Zoosters and Lionesses throw Marty a surprise birthday party, but when he shares his wish to go to the wild, they burst his bubble by telling him he’s crazy. After the other animals leave, Alex sticks around to cheer up his buddy and talk him out of leaving. Despite the pep talk, Marty escapes from the zoo.
Alex, Gloria and Melman scour the city among the New Yorkers (including Passerby, Newspaper Man, and Old Lady) in search of their friend. Candy Hammernose and cameraman film the chaos of the animals escaping the zoo. Once the Zoosters are reunited, everyone tries to remain calm despite the commotion of the city and the threat of capture by Police Officer #1, Police Officer #2, and Animal Control Officers. Tranquilizer shots bring the adventure to an end ("Grand Central"), and the animals fall asleep. When they awaken, the Zoosters; Mason, a chimpanzee; and the Penguins are trapped in crates on a ship bound for Africa. The Penguins take control of the ship from the Ship's Captain and steer wildly, causing the other animals’ crates to fall overboard. Unaware, the Penguins set off for Antarctica.
The Zoosters reunite on land, suspecting that they have been moved to the San Diego Zoo. After saving the Lemurs (including Lynn, Lew, Lee, Lars, Lemur Soloists, and Maurice) from the Foosa Leader and Foosa, catlike carnivorous creatures, the gang is welcomed to Madagascar by the herd of Lemurs and the illustrious King Julien the 13th, who gets the party started ("I Like To Move It"). As everyone gets acquainted, King Julien makes friends with the newcomers in hopes that the herd will continue to be protected from the Foosa. Seaweed-on-a-stick is the only food the Lemurs have to offer their guests, but they provide the Zoosters a comfortable place to sleep. Everyone is content as they drift off to sleep except for Alex, whose appetite was not satisfied by the seaweed.
Meanwhile, the Penguins reach Antarctica but promptly turn around when they realize it is not the paradise they expected. When Alex, Melman, Gloria and Marty wake the next day, it appears that Marty’s birthday wish has come true ("Living In Paradise"). However, things take a turn when Alex’s natural instincts begin to surface. Worried he might hurt his friends, Alex leaves. The Penguins arrive with the ship, and Marty sneaks away to find Alex in Foosa territory ("Foosa Hungry"). Alex warns Marty to go away, but Marty refuses. As the Foosa surround Marty, Alex hatches a plan and the others arrive just in time to help scare the Foosa away ("The King Of Madagascar"). Everyone celebrates: the Lemurs are safe, the friends are reunited, and the Penguins have the ship to take everyone home ("Together Forever"). One last song and the journey to Madagascar is complete!