It is three years after the Clone Wars. The leader of the droid army, General Grievous, has captured Chancellor Palpatine on board his ship, the Invisible Hand. Jedi Master Obi-Wan Kenobi and Jedi Knight Anakin Skywalker must fly through Coruscant safely, and enter the Invisible Hand so that they can rescue the captive Chancellor. Just when Palpatine is about to be released, Count Dooku shows up. Obi-Wan and Anakin both battle it out with him, but Obi-Wan ends up unconscious. Anakin slices off his head and kills him. Anakin carries Obi-Wan, and Palpatine follows him. They meet General Grievous face to face, and Anakin tries to fly the last half of the ship so that they can safely land on Coruscant. Later, Palpatine starts acting strange, constantly manipulating Anakin into believing that the Jedi Council is against him. Eventually, it is found out that he is the Dark Lord of the Sith. Jedi Master Mace Windu fights him, along with three other Jedi that accompany Windu. They all fail. Anakin becomes Darth Vader, believing that he can save Padme from death by becoming evil. After a fierce battle between Obi-Wan and Anakin, Anakin gets fried by the lava at Mustafar. Palpatine takes him to a medical facility, where he gets fake legs and a fake arm attached to him, along with a breath mask, and a helmet. And thus, Darth Vader was born...the Death Star is shown under construction, a weapon of mass destruction that is sure to be used in the future.
During the escape, the ship is attacked by the Federation blockade, forcing R2-D2, one of the ship's droids, to fix the shields. The attack damages the ship's hyperdrive, forcing the party to land on the desert planet of Tatooine for repairs. While searching for needed parts, Qui-Gon and a handmaiden named Padmé befriend young Anakin Skywalker (Jake Lloyd), a nine-year-old human slave gifted in piloting and mechanics. Qui-Gon senses a strong presence of the Force in Anakin, and feels that he may be the "Chosen One" an individual the Jedi believe will fulfill a prophecy by bringing balance to the Force. At Anakin's insistence, Qui-Gon enters Anakin into the Boonta Eve Podrace in a bid with Anakin's master, Watto, to gain the needed parts as well as Anakin's freedom. Anakin eludes several obstacles including rival racer Sebulba to win the race, gaining his freedom and bankrupting Watto. After hesitation, Anakin leaves his mother and his droid, C-3PO (Anthony Daniels), behind on Tatooine to go with the Jedi. As the group prepares to depart, they are attacked by the Sith apprentice Darth Maul (Ray Park), who battles Qui-Gon until the heroes escape.
On Coruscant, Qui-Gon informs the Jedi Council of the mysterious, well-trained attacker. The Council becomes concerned that this may indicate the reappearance of the Sith, an opposing order that followed the dark side of the Force. Qui-Gon informs the Council about Anakin, hoping that he can be trained as a Jedi. After testing the boy the Council refuses, worried that he is too old for training and that the fear and anger that he harbors will cloud his future. Meanwhile, Senator Palpatine (Ian McDiarmid) of Naboo persuades Amidala to call a vote of no confidence in Chancellor Valorum. The vote removes Valorum from power and leads to Palpatine's nomination for the position, which Amidala considers too late to be effective. To stop the Federation invasion by herself, the Queen decides to return to Naboo with her security team, the two Jedi, R2-D2, Anakin, and Jar Jar.
On Naboo, Padmé reveals herself as Queen Amidala and forms an alliance with the Gungans for the battle against the Trade Federation. The Gungans march into battle to divert the Federation army away from the capital, allowing the others to infiltrate the palace. Once inside the palace hangar, the Jedi free several Naboo pilots, who regain their starfighters and assault the Federation droid ship. As they make their way to the throne room, the infiltration team is confronted by Darth Maul. Qui-Gon and Obi Wan engage Maul while the others take an alternative route. Qui-Gon and Obi-Wan duel with the Sith Lord amongst the catwalks of a massive power-generating reactor core. Obi-Wan is briefly delayed, separating him from Qui-Gon and Maul. Meanwhile, Queen Amidala and her forces fight their way into the palace and capture Nute Gunray, Viceroy of the Trade Federation. Anakin - who inadvertently joined the dogfight in space - destroys the droid-control ship's reactor with proton torpedoes, which deactivates the droid army in the midst of taking Gungan prisoners. In the reactor core, Qui-Gon re-engages Darth Maul singlehandedly, but is mortally wounded. Obi-Wan catches up with and defeats Maul in another intense lightsaber battle. With his final breath, Qui-Gon instructs Obi-Wan to train Anakin to become a Jedi.
In the aftermath, the newly elected Chancellor Palpatine congratulates Queen Amidala on her victory and promises to watch Anakin's career with great interest. Meanwhile, the Jedi Council promotes Obi-Wan to the level of Jedi Knight, and Yoda reluctantly accepts Obi-Wan's request to train Anakin as his padawan. During Qui-Gon's funeral, Mace Windu (Samuel L. Jackson) and Yoda (Frank Oz) agree that Maul was killed by Obi-Wan. However, because there are always two Sith at any given time (a master and an apprentice), they believe that another Sith still exists, although who is that Sith is uncertain. A large celebration is held on Naboo to celebrate the world's liberation and the newborn alliance between the Naboo and the Gungans.