The principal characters are a zebra called Marty, a lion called Alex, a giraffe called Melman and hippopotamus called Gloria.
At the Central Park Zoo, Marty is celebrating his birthday and he says to his friends that he would like to see what is outside the zoo. At night, Marty talks to the penguins because they also want to escape from the zoo and they give them some tips. He decides to go to the train station and go to Connecticut for the night. When Gloria, Alex and Melman discovered what he has done they follow him. At the station the four friends, with the penguins and two chimpanzees are sedated with tranquilizer darts. The zoo, under pressure from animal-rights activists, decides to send the animals to a Kenyan wildlife preserve. During their travels, the penguins escape from their enclosure and take over the ship, intent on taking it to Antarctica. Their antics on the bridge cause the crates containing Alex, Marty, Melman, and Gloria to fall off the boat and wash ashore on Madagascar.
The animals believed themselves to be in San Diego but there, they meet a pack of lemurs led by King Julien XIII and they learn their location. Alex gets angry with Marty because he wants to come back to the civilization but Marty, Melman and Gloria are enjoying the island. The problems start when Alex starts showing his hunting instincts because he had been away from the prepared steaks for too long. The group is accepted by the lemurs, though King Julien's adviser, Maurice, cautions them about Alex's predatory nature. King Julien ignores Maurice's concerns and persuades the group to help the lemurs fend off the fossa, who hunt the lemurs as prey. While initially Alex scares the fossa away and is worshiped by the lemurs, he becomes delusional because of his starvation and attacks Marty. Unable to overcome his instincts and hunger, King Julien banishes Alex to the far side of the island, where the fossa live. Marty begins to regret seeing what Alex has turned into.
The penguins come back from the Antarctica because they had not liked it. Marty, Gloria and Melman run to tell Alex that with the ship they could come back to New York. When they are in the far side of the island they are attacked by the fossa but Alex appear and save them. When they go to the beach they discover that the ship has run out of fuel but the penguins satisfy Alex’s craving of meat with sushi.