Two years after Larry Daley (Ben Stiller) defeated the three night guards plotting to steal The Tablet, he is now head of Daley Devices, a company that he founded to manufacture his inventions. These inventions, including the Glow-in-the-Dark Flashlight, were created from his experiences as a former night guard. He finds that the American Museum of Natural History is closed for upgrades and renovations, and some of the museum pieces are being replaced by interactive holograms. The actual exhibits are moved to the Federal Archives at the Smithsonian Institution in Washington DC. On the last night, Larry meets the museum pieces such as Teddy Roosevelt (Robin Williams), Rexy the Tyrannosaurus Skeleton, and Dexter the Capuchin Monkey (Crystal the Monkey) and finds out that several exhibits, including Teddy, Rexy, the Easter Island Head (Brad Garrett), and good Pharoah Ahkmenrah (Rami Malek) and his Tablet are not moving to The Smithsonian Institution - without the Tablet of Ahkmenrah, the other exhibits will no longer be animated. The next night, Larry gets a call from Jedediah (Owen Wilson), saying that Dexter stole the tablet last midnight and evil Pharaoh Kahmunrah (Hank Azaria), Ahkmenrah's older brother, is attacking them. Larry goes to Washington and visits the National Air and Space Museum, the National Gallery of Art and the Smithsonian Castle to find the Federal Archives with the help of his son Nick (Jake Cherry). Larry sneaks into the archives and locates the exhibits, frozen in the middle of a battle with Kahmunrah and his troops, who are trying to lock the exhibits in a crate. Larry gets hold of the Tablet of Ahkmenrah, which had been stolen by Dexter, just when the sun sets and all the exhibits come alive again. Kahmunrah and his troops lock the crate and take the Tablet from Larry, and he tells Larry that bringing the exhibits to life is just one of the tablet's powers - he intends to use it to raise an army from the underworld and conquer the world. Larry escapes with the help of General George Armstrong Custer (Bill Hader), who gets captured, and meets Amelia Earhart (Amy Adams), who is thrilled at the prospect of adventure and accompanies Larry.Larry and Amelia then go through an assortment of paintings and trap Kahmunrah's men in one. Meanwhile, Kahmunrah is able to recruit black and white agent Al Capone (Jon Bernthal), evil Russian emperor Ivan The Terrible (Christopher Guest) and French Ruler/General Napoleon Bonaparte (Alain Chabat) to help him capture Larry in return for sharing the world with him when he conquers it. Custer is locked up with the other exhibits from the American Museum of Natural History, and while he conceives a poor plan of attack (he will scream "Attack!" and the exhibits will jump out and attack), Jedediah and Octavius (Steve Coogan) sneak out to help Larry. Larry and Amelia are captured and taken to Kahmunrah. Kahmunrah then attempts to activate the tablet to open the gates of the underworld by pressing the symbols on the tablet, only to find out that the combination has been changed. He orders Larry to decipher the tablet's riddle and figure out the new combination before sunrise, and traps Jedediah in an hourglass to hasten his attempts. Larry and Amelia consult a bust of Teddy who says that the answer is in the heart of the pharaoh's tomb. The duo then consult The Thinker, but he gets distracted by a beautiful statue of a woman. Finally, at the National Air and Space Museum, they consult a group of Albert Einstein bobbleheads who tell them that the answer to the riddle (and hence the new combination) is pi. Larry and Amelia fly the Wright Flyer back to the Museum of Natural History, and Amelia goes for help while Larry delays Kahmunrah. Capone, Napoleon and Ivan arrive and tell him the code, and he opens the gates of the underworld and summons an army of bird-men. Suddenly, the statue of Abraham Lincoln from the Lincoln Memorial bursts through the window, frightening the bird-men back to the underworld. Amelia arrives, having freed the other exhibits, and Custer orders them to attack. Larry duels Kahmunrah with his flashlight, defeating him and then pushing him through the gate, which banishes him to the underworld forever. Amelia flies Larry and the other exhibits back to the American Museum of Natural History, where Teddy welcomes him back, and Larry assures him he has a way for them to remain there. Larry and Amelia say goodbye and kiss before Amelia flies away, leaving Larry outside the museum. Some time later, it is revealed that Larry sold his company and donated the money to the museum to pay for Audio-Animatronics exhibits - since the museum now opens late, the exhibits can come to life under the guise of animatronically animated exhibits, including Teddy as a tour guide, Ahkmenrah and Dexter displaying the Tablet, and Attila as a storyteller. Larry is rehired at the museum as the night guard, and meets a young woman who looks just like Amelia. The film concludes as they talk and walk off as Larry guides her toward the hall of miniatures. During the credits, a man from a black and white photo of V-J day in Times Square is seen examining Larry's Blackberry cell phone, which Larry left in the photo, and makes a new discovery (for his time period). His mother calls him, and it is revealed that his name is Joey Motorola.