In Africa, Zuba the lion tries to teach his son Alakay how to fight, but the cub is more interested in dancing. Rival male Makunga challenges Zuba for the title of alpha lion, and during their fight Alakay is captured by poachers. The crate containing Alakay falls into the ocean and drifts to New York City, where he is renamed Alex and grows up at the Central Park Zoo with Marty the zebra, Melman the giraffe, and Gloria the hippopotamus.
Years later, following their adventure in Madagascar, the zoo animals—Alex, Marty, Melman, Gloria, the penguins Skipper, Kowalski, Rico, and Private, and chimpanzees Mason and Phil—prepare to return to New York aboard a battered airplane piloted by the penguins, accompanied by the lemurs King Julian, Maurice, and Mort. The plane runs out of fuel and crash lands in continental Africa. The animals find themselves at a watering hole on a nature reserve, and are excited to meet others of their species. Alex is reunited with his parents and impresses them with tales of his status as “the king of New York”. Marty fits in with a herd of other zebras who look and sound just like him. Melman, a hypochondriac, is distressed that the reserve has no doctors, so the other giraffes appoint him their witch doctor. Seeking romance, Gloria attracts the attention of the smooth-talking male hippo Moto Moto.
Meanwhile, the penguins set about repairing the plane, assisted by numerous chimpanzees recruited by Mason and Phil. They steal vehicles from several groups of New Yorkers who are on safari and strip them for parts. Nana, a tough old woman who slapped Alex around during the events of Madagascar, takes charge of the stranded tourists and helps them survive in the wilderness.