Two years after the events of the previous film, Larry Daley is now CEO of Daley Devices, a direct response television company that sells inventions inspired by his experiences as a night security guard at the American Museum of Natural History. While wealthy and successful he has not had the time to see his museum exhibit friends in several months.
When Larry returns to the museum he learns that it is closed for renovations and upgrades. Interactive holograms will replace many of the exhibits, which are moving to the Federal Archives at the Smithsonian Institution in Washington DC. While Theodore Roosevelt , Rexy the Tyrannosaurus skeleton, the Easter Island moai , and the Mummy of Akhmenrah will remain at the museum, Jedediah , Dexter the Capuchin Monkey, Octavius and others will no longer come to life since the Golden Tablet of Akhmenrah that animated the exhibits each night will also remain.
After the exhibits leave, Larry receives a distress call from Jedediah. Dexter stole Akhmenrah's tablet and brought it to the Federal Archives, and the evil Pharaoh Kahmunrah , Akhmenrah's older brother, is attacking Jedediah and the other exhibits. Larry travels to Washington and visits the National Air and Space Museum, the National Gallery of Art, and the Smithsonian Institution Building, searching for the Federal Archives with long-distance help from his son Nick .
Larry tricks an over-protective guard named "Brandon" (pronounced "Brundon") into giving him his card key and after dressing up as a Smithsonian night guard, he locates the exhibits, frozen in their shipping container in the middle of a battle with Kahmunrah and his troops. As Larry obtains the tablet the sun sets and the exhibits, and others at the Smithsonian, come alive. Kahmunrah forces Larry to give him the tablet, then tells Larry that bringing the exhibits to life is just one of the tablet's powers, and that he intends to use it to conquer the world by raising an army from the underworld.
Larry tries to dupe Kahmunrah into giving back the tablet, by telling him about the cube of rubik although is threatened by Kahmunrah. Larry escapes from the Egyptian troops with the tablet, with the help of General George Armstrong Custer . He meets the beautiful and adventurous Amelia Earhart who is attracted to Larry and accompanies him through the National Gallery. Larry and Amelia trap some of Kahmunrah's soldiers in a photograph of V–J day in Times Square, but are later captured by Napoleon Bonaparte and his soldiers. Napoleon takes Larry to Kahmunrah who has also allied with historical leaders Ivan the Terrible and Al Capone . Kahmunrah has rejected fellow villains Darth Vader and Oscar the Grouch . Meanwhile Custer is captured and locked in the same shipping container as the rest of the exhibits. Custer begins planning a counter-attack, but his plans are refuted as foolish by Sacagawea . Jedediah and Octavius, also skeptical of Custer's abilities, become concerned for Larry's safety, and try to escape in a effort to help him. However, Jedediah is captured in the escape attempt and is brought before Kahmunrah in a birdcage. Octavius, watching from a window, vows to rescue Jedediah.
Kahmunrah attempts to open the Gate of the Underworld by pressing the symbols on the tablet, which resembles numbers on a keypad, but the combination has changed. Larry calmly states that he can simply wait until sunrise, and then reclaim the tablet while Kahmunrah and his henchmen are frozen. The pharaoh forces Larry to obtain the new combination before sunrise by trapping Jedediah in a filling hourglass. Unless Larry figures out the new combination in less than an hour, Jedediah will be smothered by the falling sand. Larry and Amelia begin searching for someone who can tell them the new combination, but their movements lead Kahmunrah to believe that they are trying to escape with the tablet, rather than decipher the new combination. In response, Kahmunrah orders Ivan the Terrible to dispatch Russian troops to track them down. Larry and Amelia flee from the Russians and hide at the Lincoln Memorial. The statue of Abraham Lincoln then comes to life, and he has a short conversation with Larry and Amelia. At the National Air and Space Museum, they consult a group of Albert Einstein bobbleheads who tell them that the new combination is the value of pi . When they are found by Napoleon, Ivan, and Capone , Larry and Amelia escape in the Wright Flyer and return to the Smithsonian Institution Building. The two separate, with Amelia searching for help while Larry delays Kahmunrah. Octavius, still searching for a way to save Jedediah, arrives at the White House, because he was told that "a good man lives ." Octavius rushes to the White House, but is attacked and dragged away by a squirrel.
Larry then approaches Kahmunrah, telling him that if he returns Jedediah, Larry will give him the combination. Kahmunrah replies that Larry must first give him the combination; only then will he free Jedediah. The two argue back and forth until Napoleon, Ivan, and Capone arrive, having obtained the combination themselves from one of the bobbleheads. Kahmunrah opens the Gate of the Underworld and summons an army of Horus warriors. Suddenly, Octavius reappears, riding the same squirrel that dragged him away earlier. He charges Kahmunrah, demanding surrender. Kahmunrah begins to laugh when the Lincoln statue suddenly arrives, forcing the horus warriors to retreat to the underworld, and Amelia frees the New York exhibits from their container and recruits other Smithsonian exhibits. Custer leads the exhibits against Kahmunrah, Napoleon, Ivan the Terrible and their henchmen. Amidst the chaos, Octavius rescues Jedediah from the hour-glass. Larry then tricks Napoleon, Ivan the Terrible, and Al Capone into fighting amongst themselves. As the exhibits battle, Larry banishes Kahmunrah to the underworld. After the fighting ends, Amelia flies Larry and the New York exhibits back to the Natural History Museum. Knowing that she will turn to dust at sunrise if she does not return to the Smithsonian, Amelia kisses Larry and leaves.
Larry sells his company and donates money to the museum to restore the exhibits. Roosevelt and Akhmenrah as tour guides, Attila as a storyteller, and other exhibits come to life in public as "animatronics" at the museum, which now stays open after sunset. Larry is rehired as the night guard, and meets a young woman who looks like Amelia.