Originally, Julien was intended to be a minor character with only two lines. However, when Sacha Baron Cohen auditioned for the role, he improvised not only an Indian accent, but eight minutes of dialogue for his recording. The filmmakers found Cohen's performance so funny that they rewrote the script and made Julien a much more prominent character 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.
The scene where Alex dreams about steaks slowly falling down on him spoofs an iconic scene from the Dreamworks movie American Beauty (1999), where Lester Burnham dreams of roses falling down on his daughters friend, Angela. The same song is played in both scenes.
David Schwimmer, who voices Melman the Giraffe, played Ross Gellar in 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).
In the original movie trailer Mason the monkey was holding a martini glass while in the movie he was holding a teacup with a plate. The reason was tea and root beer were okay for the monkeys to use instead of drinking beer.
In the director's audio commentary Mort the mouse lemur who is young sweet and cute was originally going to have a joke where he was really 37 years old and the other lemurs called him on that age. But they cut it out for time issues.
When the Penguins unwittingly tunnel into Marty's enclosure, and Skipper says to Marty 'can you keep a secret my monochromatic friend?' He is technically right, even though zebras have two-tone stripes. Monochromatic means one color. Black can always be represented as it is 0% of a color, regardless of which - as technically black is the absence of light/colour. However, to refer to white as monochromatic is somewhat strange as it uses all possible colours.