Larry Daley (Ben Stiller) is a divorced man who has been unable to keep a stable job and has failed at many business ventures. His ex-wife (Kim Raver) believes that he is a bad example to their ten-year-old son Nick (Jake Cherry), and Larry fears that Nick respects his future stepfather, bond trader Don (Paul Rudd), more than him.
Cecil Fredricks (Dick Van Dyke), an elderly night security guard about to retire from the American Museum of Natural History, hires Larry despite his unpromising résumé. The museum, which is rapidly losing money, plans to replace Cecil and two colleagues Gus (Mickey Rooney) and Reginald (Bill Cobbs) with one guard. Cecil gives Larry an instruction booklet on how to handle museum security, and advises Larry to leave some of the lights on and warn him not to let anything “in…or out”.
Once night falls, Larry discovers that the exhibits come to life, including a living Tyrannosaurus skeleton nicknamed “Rexy” who behaves like a dog; a mischievous capuchin monkey named Dexter (Crystal) which steals Larry’s keys and tears up his instruction booklet; rival miniature civilizations led by Old West cowboy Jedediah (Owen Wilson) and Roman general Octavius (Steve Coogan); limb-ripping Attila the Hun; an Easter Island Moai (Brad Garrett) obsessed with “gum-gum” who addresses Larry as Dum-Dum; and a wax model of Theodore Roosevelt (Robin Williams).
Roosevelt explains that since an Egyptian artifact—the Golden Tablet of Pharaoh Akhmenrah—came to the museum in 1952, all of the exhibits come to life each night. If the exhibits are outside the museum during sunrise, however, they turn to dust. Roosevelt helps Larry by restoring order, but only for one night, and Larry decides to remain as a night guard.
When Larry tells Cecil about how Dexter tore up his instructions, Cecil advises him to study history to prepare himself for his nightly duties. He also learns history from a museum docent Rebecca Hutman (Carla Gugino), who is writing a dissertation on Sacagawea (Mizuo Peck), but does not feel she knows enough about her subject.
The next night, Larry uses what he has learned to better control the exhibits. However, things go wrong and four Neanderthals set fire to a display and some other things. One of the Neanderthal turns to dust when he leaves the museum at dawn. The next morning, museum director Dr. McPhee (Ricky Gervais) almost fires Larry after what happened to the Neanderthal exhibit. He offers Rebecca a meeting with Sacagawea, but she believes that he is mocking her and the museum.