In the future, robots known as Sentinels are exterminating mutants and their human allies. A band of mutants, including Kitty Pryde, Colossus, Iceman, Bishop, Warpath, Blink and Sunspot, evade the Sentinels due to Pryde’s ability to send a person’s consciousness to the past. Pryde’s group convenes with Logan, Storm, Professor Charles Xavier, and Erik Lehnsherr at a monastery in China. Pryde sends Logan’s consciousness 50 years back in time to 1973 to prevent Mystique from assassinating Dr. Bolivar Trask, creator of the Sentinels. Following the assassination, Mystique was captured, and her DNA was used by Trask’s company to improve the Sentinels, whose ability to adapt to any mutant power makes them almost invincible. Xavier and Lehnsherr advise Logan to find both of their younger selves for help.
At the X-Mansion in 1973, Logan encounters Xavier and Hank McCoy. Xavier’s Institute for Gifted Youngsters has closed after most of the teachers and students were drafted to the Vietnam War. Xavier, a broken man, has been overusing a serum that allows him to walk but suppresses his telepathy. Logan explains his mission and persuades Xavier to help free Lehnsherr from a prison cell beneath The Pentagon, where he is being held for allegedly assassinating President John F. Kennedy. They rescue Lehnsherr with the help of Peter Maximoff, a mutant with super speed.
In Washington D.C., Trask unsuccessfully tries to sway 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 for his experiments. Xavier, Lehnsherr, McCoy, and Logan fly to Paris to intercept Mystique, who is impersonating a North Vietnamese general to infiltrate the Paris Peace Accords. There, Trask attempts to sell his Sentinel technology to Communist nations. Xavier’s group arrives as Mystique is about to kill Trask. Lehnsherr tries to kill Mystique to ensure her DNA cannot be used for the Sentinels, but she jumps from a window. The fight spills onto the street in view of the public, allowing Lehnsherr 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, Lehnsherr—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 Logan, 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, Logan, and McCoy search for Mystique, Nixon unveils the Sentinel prototypes at the White House. Lehnsherr commandeers the Sentinels and attacks the crowd, then sets 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. Logan and McCoy try to stop Lehnsherr, but he pits a Sentinel against them and then throws Logan into the Potomac River. In the future, the X-Men make their final stand as a large army of Sentinels attack the monastery. In 1973, Lehnsherr pulls the safe room from the White House and prepares to kill Nixon and his Cabinet. Mystique, who is disguised as Nixon, incapacitates Lehnsherr with a plastic gun. Xavier persuades Mystique to spare Trask and allows her and Lehnsherr 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.
Logan wakes up in the future to find Iceman, Rogue, Colossus, Kitty, McCoy, Storm, Jean Grey, Scott Summers, and Xavier are all alive. In 1973, Mystique, impersonating Stryker, takes custody of Logan.
In a post-credits scene, a crowd chants to En Sabah Nur, who is using telekinesis to build pyramids as four horsemen watch from nearby.