Anakin Skywalker appears as a nine-year-old slave in Star Wars Episode I: The Phantom Menace. He is raised on the planet Tatooine by his mother, Shmi, who says Anakin had no father, implying miraculous birth. He is a gifted pilot and engineer, and has the ability to "see things before they happen". He even creates his own protocol droid, C-3PO. Jedi Master Qui-Gon Jinn meets him after an emergency landing on Tatooine and becomes convinced the boy is the "Chosen One", foretold by a Jedi prophecy as the one who will bring balance to the Force. Anakin wins his freedom in a podrace, but is forced to part with his mother. Qui-Gon takes Anakin to the Jedi Council, who forbid training on the grounds that the boy's future is clouded by the fear he exhibits. During the invasion of Naboo, Anakin helps defeat the Trade Federation by destroying their command ship. After Qui-Gon is killed in a duel with Sith Lord Darth Maul, his apprentice, the young Obi-Wan Kenobi (Ewan McGregor), promises to train Anakin, a proposal the Jedi Council reluctantly accepts. During the film, Anakin forms a close bond with Padmé Amidala, Naboo's elected queen. Palpatine, newly elected as the Republic's Supreme Chancellor, befriends the boy, telling him that "we will watch your career with great interest."
Star Wars Episode II: Attack of the Clones, set 10 years later, depicts Anakin as Obi-Wan's Padawan learner. Palpatine assigns Anakin and Obi-Wan to investigate an assassination attempt made on Padmé, who is now a senator. Anakin travels with her to Naboo, where they fall in love, despite Padme resisting her feelings for him. Anakin has a vision of his mother in pain, and goes to Tatooine, where he learns that Shmi had been kidnapped by Tusken Raiders. He goes to the Tusken camp, where he finds his mother, mortally injured; she dies in his arms. Seized by a violent rage, Anakin slaughters the entire tribe. He returns with his mother's body, and tearfully admits his crime to Padmé, who comforts him. Soon after, Anakin and Padmé travel to Geonosis, hoping to rescue Obi-Wan from Jedi-turned-Sith Lord Count Dooku and his army of Separatists; instead, they are captured and sentenced to be executed. Anakin and Padmé confess their love for each other moments before being rescued by an army of clone troopers and Jedi. Anakin loses his right arm in a lightsaber duel with Dooku; it is replaced with a prosthetic. At the end of the film, Anakin and Padmé marry in a secret ceremony.
In Star Wars Episode III: Revenge of the Sith (2005), set three years later, Anakin is a Jedi Knight and hero of the Clone Wars. He and Obi-Wan lead an attempt to rescue Palpatine, who has been kidnapped by Dooku and the Separatist leader General Grievous. During the rescue, Anakin defeats Count Dooku in a grueling lightsaber duel after tapping into his anger and hate, aspects of the dark side of the Force. He then decapitates Dooku in cold blood at Palpatine's urging, thus starting him down the path to the dark side. When he returns to Coruscant, he meets with Padmé, who tells him she is pregnant with his child. That night, he has a vision of Padmé dying in childbirth; he fears it will come true, as it is similar to visions he had of his mother before she died. Meanwhile, Palpatine names Anakin his representative on the Jedi Council; the Council, suspicious of Palpatine's dictatorial power in the Senate, denies Anakin the customary rank of Jedi Master, and ask him to spy on Palpatine, whom Anakin considers a friend.
Palpatine eventually reveals to Anakin that he is the Sith Lord Darth Sidious, the mastermind behind the war, and that the dark side holds the power to save Padmé's life. Conflicted, Anakin reports Palpatine to Jedi Master Mace Windu. Despite orders to remain behind, Anakin follows Windu to the chancellor's office to ensure Palpatine is captured alive; he also severs Windu's lightsaber arm. Palpatine kills Windu with a blast of Force lightning. Anakin, desperate to save his wife, pledges himself to the Sith as Palpatine's apprentice, Darth Vader.
Palpatine sends Vader to kill everyone inside the Jedi Temple, in which he duels and kills the Jedi Masters and younglings, and then to assassinate the Separatist leaders on Mustafar as part of his plans to transform the Republic into the Galactic Empire. Padmé meets him there and pleads with him to flee Palpatine's grasp with her. He refuses, saying that the two of them can overthrow Palpatine and rule the galaxy. When Obi-Wan emerges from Padmé's ship, Vader accuses her of conspiring against him and uses the Force to choke her into unconsciousness. Vader then engages Obi-Wan in an epic lightsaber duel in which both combatants seem evenly matched, though Obi-Wan is continually pushed back by Vader's rage. At the end, Obi-Wan leaps to safety on higher ground and warns Vader not to follow. Vader ignores the warning, believing his power to be great enough to overcome the tactical disadvantage. He attempts to flip over Obi-Wan, leaving himself open for attack. The duel ends with Obi-Wan severing Vader's legs and left arm while Vader is in mid-air. Vader then slides down the hill too close to a lava flow and is immolated. Obi-Wan shouts in agony that Anakin, now Vader, was the Chosen One, who was supposed to bring balance to the force rather than leave it in darkness. Obi-Wan then picks up Vader's lightsaber and leaves him to die. Under medical care on Polis Massa, Padmé delivers twins — Luke and Leia — and dies.
Palpatine rescues Vader and through extensive surgery, reconstructs his apprentice's ruined body with the cybernetic limbs, various implants and black armor, which includes the black helmet which functions as a ventilator to help Vader breathe from his badly scarred lungs, which is first seen in A New Hope. When Vader regains consciousness, Palpatine tells him Padmé died as a result of Vader's anger; this revelation breaks what remains of Vader's spirit and humanity, and he screams in torment over feeling cheated by Padmé's loss. He is last seen alongside Palpatine and a young Grand Moff Tarkin viewing the construction of the first Death Star.