In the future, robots known as Sentinels are exterminating all mutants and any humans who to help them or harbor mutant genes. A band of mutants evade the Sentinels with the help of Kitty Pryde, who can project a person's consciousness into the past to deliver warnings. Pryde's group convenes with Storm, Wolverine, Professor Xavier, and Magneto in China. Pryde sends Wolverine's consciousness to 1973 to prevent Mystique from assassinating Bolivar Trask, the creator of the Sentinels. Following the assassination, Mystique was captured and her DNA was used by Trask's company to create Sentinels, whose ability to adapt to any mutant power makes them almost invincible. Xavier and Magneto advise Wolverine to find both of their younger selves for help. Wolverine awakens in 1973. At the X-Mansion, he encounters Xavier and Beast. Xavier's Institute for Gifted Youngsters has closed after most of the teachers and students were drafted for the Vietnam War. Xavier, now a broken man, takes a serum which allows him to walk and suppresses his telepathy. Wolverine explains his mission and persuades Xavier to help free Magneto from a prison cell beneath the Pentagon, where he is being held for allegedly assassinating President John F. Kennedy. They rescue Magneto with the help of Peter Maximoff, a mutant with superhuman speed.
In Washington D.C., Trask unsuccessfully lobbies Congress to gain support for his Sentinel program. Meanwhile, in Saigon, Mystique prevents William Stryker from appropriating a group of mutant G.I.s for Trask's research. Mystique investigates Trask's office and discovers he has been capturing mutants to use in experiments. Xavier, Magneto, Beast, and Wolverine fly to Paris to intercept Mystique. In Paris, Mystique impersonates a Vietnamese general to infiltrate the Paris Peace Accords with Trask, who is trying to sell his Sentinel technology to communist nations. Xavier, Magneto, Beast, and Wolverine arrive as Mystique is about to kill Trask. Magneto tries to kill Mystique to ensure her DNA cannot be used for the Sentinels, but she flees from a window. The fight spills onto the street in view of the public, allowing Magneto and Mystique to escape. Trask is saved but the world is horrified by the existence of mutants. President Richard Nixon approves Trask's Sentinel program and arranges an unveiling ceremony. Trask's scientists recover Mystique's blood from the street. Meanwhile, Magneto—who has recovered his telepathy-blocking helmet—intercepts the prototype Sentinels in transit and laces their polymer-based frames with steel, allowing him to control them. At the mansion, Xavier stops taking his serum and slowly regains his mental powers while losing the ability to walk. Through Wolverine, Xavier speaks to his future self and is inspired to work for peace between humans and mutants once again. He uses Cerebro to track Mystique, who is heading to Washington D.C. As Xavier, Wolverine, and Beast search for Mystique, Nixon unveils the Sentinel prototypes at the White House. Magneto commandeers the Sentinels and attacks the crowd then uses the Robert F. Kennedy Memorial Stadium around the White House as a barricade. Nixon and Trask, accompanied by the Cabinet, Secret Service officers, and Mystique disguised as a Secret Service member, are taken to a safe room. Wolverine and Beast try to stop Magneto but he pits a Sentinel against them and throws Wolverine into the Potomac River. In the future, the X-Men make their final stand as a large army of Sentinels attack a monastery. In 1973, Magneto pulls the safe room from the White House and prepares to kill Nixon and his Cabinet. Mystique, disguised as Nixon, incapacitates Magneto with a plastic gun. Xavier persuades Mystique to spare Trask and allows her and Magneto to flee. Mystique's actions are seen as a mutant saving the President, leading to the cancellation of the Sentinel program. Trask is arrested for trying to sell American military secrets. Wolverine wakes up in the future and finds that Iceman, Rogue, Colossus, Pryde, Beast, Storm, Jean Grey, Cyclops, and Xavier are alive. In 1973, Mystique impersonates Stryker and takes custody of Wolverine. In a post-credits scene set in Ancient Egypt, a crowd chant to En Sabah Nur, who is using telekinesis to build pyramids as the four horsemen keep watch nearby.