Originally, Julien was intended to be a minor character with only two lines. However, when they cast Sacha Baron Cohen for the role, he improvised not only an Indian accent, but eight minutes of dialogue for his recording. The producers found Cohen's performance so funny that they decided to rewrite the script to make Julien have a much more prominent presence in the story as King of the Lemurs.
Sacha Baron Cohen improvised the line "It's got a gecko on it", and all of the following dialog related to the gecko. The filmmakers found it so funny that they went to the extra work of creating a CG gecko for the shot.
Melman the giraffe wears tissue boxes on his feet. This is a reference to Howard Hughes who was also a hypochondriac and suffered OCD (obsessive compulsive disorder). In his later years, Hughes wore tissue boxes on his feet believing this would keep away germs.
When the camera pans backward from Alex's crate in the ocean, the sea foam around him creates the head of a lion. Foam makes the face, and the absence of foam around that makes the mane. Alex is in the left eye of the face.
When Private is attempting to commandeer the oil tanker, "WHATApiece OFworkIsPenGuin" can been seen on the computer screen behind him. This spoofs the William Shakespeare quote, "What a piece of work is man!" from "Hamlet".
The penguins originated from a film director Eric Darnell was developing, called "Rockumentary", about The Beatles-like rock quartet. When that project was canceled and Darnell was moved to this movie, he incorporated the penguins into the script, changing them from musicians to military commandos.
David Schwimmer, who voices Melman the Giraffe, also plays Ross Gellar, one of the main characters in the show "Friends" (1994). In the first season, Ross had a pet capuchin named Marcel, who later in the show was given to the San Diego Zoo. When the quartet first lands on Madagascar, Melman believes it to be the San Diego Zoo.
Harry Gregson-Williams was originally attached as the film's composer, but was replaced by Hans Zimmer. A few weeks earlier, the opposite had occurred for another film: Gregson-Williams replaced Zimmer for the scoring duties of Kingdom of Heaven (2005).
The scene when Alex dreams about steaks slowly falling down on him refers to the Dreamworks movie American Beauty starring Kevin Spacey where in the movie Lester (Spacey) dreams roses fall down on Angela (Mena Suvari). The same song is played in both scenes.