Erik Magnus Lehnsherr, also known as Magneto or Henryk Gurszky is the main antagonist of the X-Men franchise. He is the main antagonist of X-Men, a major anti-hero of X2: X-Men United, the main antagonist of X-Men: The Last Stand, the villains protagonist of X-Men: First Class, the secondary antagonist of X-Men: Days of Future Past(while his older self is a supporting character), the secondary antagonist turned supporting character of X-Men: Apocalypse and a major character of X-Men: Dark Phoenix.
He was an extremely powerful mutant born to a Jewish family in Germany. During WWII, he was orphaned by the evil Nazi helper mutant Sebastian Shaw. As Erik grew up, he swore vengeance on Shaw and in 1962 he joined Charles Xavier and the X-Men to stop Shaw and his forces from beginning a new world war. Eventually, Erik killed Shaw but revealed that he intended to make mutantkind the dominant species of the world and briefly fought the X-Men, crippling Xavier in the process. He donned the title of Magneto and began his quest. While trying to save the fellow mutant and President John F. Kennedy, Magneto was framed for his death and imprisoned. Eventually, after being released he briefly joined Xavier to help the young but powerful telepath Jean Grey before abandoning him again. Years later, he and his ally and former X-Men Mystique formed the Brotherhood of Mutants and created a machine to mutate the leaders of the world and kidnapped the young X-Men Rogue to do so. However, Xavier and his new X-Men destroyed Magneto's machine, slaughtered most of his brotherhood and defeated him, leaving him to be arrested. Months later, the mutant-hater William Stryker visited Magneto and brainwashed him into revealing details about the X-Men. Magneto escaped his prison, reunited with Mystique and formed an alliance with the X-Men to save mutantkind from Stryker. Eventually, they defeated Stryker, who was then killed by Magneto, before he and Mystique parted ways with the X-Men once more. The duo then formed a much larger version of the Brotherhood of Mutants, although Magneto abandoned Mystique once she was turned into a human. When Jean Grey became the all-powerful Dark Phoenix and seemingly killed Xavier, Magneto also recruited her before launching his attack on the headquarters of the mutant cure Alcatraz to kill its manufacturer. However, the X-Men arrived and defended Alcatraz until Beast impaled Magneto with the cure, robbing him of his powers. Magneto was then among the many to escape when the Dark Phoenix lost control, just before her death. As Magneto mourned Charles, his powers arrived back to him. When Bolivar Trask created the Sentinels to end mutantkind, Magneto reformed himself and allied with the alive Xavier and the X-Men. In 2023, Wolverine travelled back in time to 1973 to stop Mystique from killing Trask, the event which sparked the creating of the Sentinels. To help him, Wolverine broke out the past Magneto(who, at this time, was still imprisoned for Kennedy's death) from his prison but Magneto betrayed them and attempted to kill Mystique after stopping her from killing Trask. His near assassination attempt on Mystique scared the public, and therefore did not stop the creation of the Sentinels. Magneto then ambushed the revealing of the Sentinels at the White House and assumed control of them, attempting to kill Trask and the President, but was defeated by Mystique. At this point in the present, Magneto was killed by the Sentinels while protecting Wolverine's body. The present timeline was erased and replaced by the timeline altered by the Wolverine after past Magneto's defeat. After seeing the error of his ways, he stopped his vengeful quest and began a family. However, his identity was discovered and his family was killed. Angry, Magneto joined the ancient mutant Apocalypse as one of his Horsemen in his attempt to wipe out humanity. Magneto nearly destroyed Earth from his core but was convinced by Xavier, Mystique and the X-Men to help them, so he finally reformed once and for all and helped them destroy Apocalypse. After that, he formed a group of mutants and began a peaceful life on the island of Genosha. However, Jean Grey became the Dark Phoenix(like she did in the original timeline) and killed Mystique, so Magneto and his forces joined Beast and attempted to end her threat, only to be arrested alongside her and the X-Men by the military. When the D'Bari race attempted to kill Jean, Magneto and the X-Men fought them off until Jean seemingly sacrificed herself and destroyed her. At an unknown point in time, Magneto died.
He was portrayed by Ian McKellen in the modern films, and by Michael Fassbender in the past films.