Marty the zebra, Alex the lion, Gloria the Hippopotamus and Melman the Giraffe live in the Central Park Zoo in New York. On Marty's tenth birthday, Marty starts to have doubts that the zoo is where he belongs, and finds that life in the zoo is boring. That night, a penguin living in the zoo named Skipper decides to break out of the zoo, and invites Marty to come with him, and gives Marty directions on how to clear paths. Skipper, in order to escape himself, is forced to abandon Marty in the process, but gives him more directions. Marty manages to make it to the main exit and leave. Realizing this, Alex, Melman and Gloria decide to go and look for him. As they find him, they are surrounded by police, tranquilized, and sent to a wild life reserve. Skipper and his team of penguins: Private, Rico and Kowalski are also on board. They escape from their crate and head for the bridge where they knock the captain unconscious and turn the ship around to Antarctica. Marty, Alex, Melman and Gloria fall into the ocean in the process. Alex is washed onto a beach unconscious, and soon wakes up. Finding an opened crate which belonging to Marty on the beach, he concludes that his friends are there too, and goes off to find them. In the jungle, he helps different animals with their tasks, and in return they give him his friends' whereabouts and finally reunites with his friends.
They go search for help, and find an entire tribe of lemurs having a party. The lemurs introduce themselves, and explain that the island they are on is called Madagascar, but as they talk, they are attacked by the fossas, the enemies of lemurs. The animals protect the lemurs, and help them collect food for another party. After the party, Gloria finds that Alex is acting strange because he didn't eat any food during the party, and tells Melman to go find steak while she goes to find Marty, Melman fails in finding steak, and meets up with Maurice, Gloria and Marty. Marty announces that Alex bit him on the butt. Maurice explains that lions are supposed to eat other animals, and that Alex never harmed animals before because in the zoo food was given to him, and the four flee to the beach. A warthog named Wilbur, who falls in love with Gloria and agrees to give them information if she gives him a kiss after the work, tells them that the rescue beacon on the beach is broken, but there are many things lying around the beach that they can use to rebuild the beacon. They collect enough materials for the beacon and finally, a beacon like the statue of liberty is built.
Marty decides that he must go back for Alex. Meanwhile, Alex is hiding in the lair of the Foosa, feeling ashamed of himself. He encounters the Fossa leader and defeats him, after which Marty arrives and rescues Alex and they give the leader to the penguins and reunite with Melman and Gloria at the beach. There, the lemurs thank the gang for their help.