Neo and Bane lie unconscious in the medical bay of the ship Hammer. Meanwhile, Neo finds his digital self trapped in a virtual subway station—named, "Mobil Ave.", "mobil", being an anagram for "limbo"—a transition zone between the Matrix and the Machine City. In that subway station, he meets a "family" of programs, including a girl named Sati, whose father tells Neo the subway is controlled by the Trainman, an exiled program loyal to the Merovingian. When Neo tries to board a train with the family, the Trainman refuses and overpowers him.
Seraph contacts Morpheus and Trinity on behalf of the Oracle, who informs them of Neo's confinement. Seraph, Morpheus and Trinity enter Club Hel, where they confront the Merovingian and force him to release Neo. Troubled by visions of the Machine City, Neo visits the Oracle, who reveals that Smith intends to destroy both the Matrix and the real world. She states that "everything that has a beginning has an end", and that the war will conclude. After Neo leaves, a large group of Smiths assimilates Sati, Seraph and the unresisting Oracle, gaining her powers of precognition.
In the real world, the crew of the Nebuchadnezzar and the Hammer find and reactivate Niobe's ship, the Logos. They interrogate Bane, who says that he has no recollection of the earlier massacre. As the captains plan their defense of Zion, Neo requests a ship to travel to the Machine City. Motivated by her encounter with the Oracle, Niobe offers him the Logos. Neo departs, accompanied by Trinity. Bane, who has stowed away on the Logos, takes Trinity hostage. Neo realizes that Bane has been assimilated by Smith and a fight ensues. Bane cauterizes Neo's eyes with a power cable, blinding him; however, Neo discovers an ability to perceive the world as golden light. Neo kills Bane, and Trinity pilots them to the Machine City.
Niobe and Morpheus set out for Zion with the Hammer to aid the human defenses against the Sentinels. In Zion, the fatally wounded Captain Mifune instructs Kid to open the gate for the Hammer. When it arrives, it discharges its EMP, disabling the Sentinels but also the remaining defenses. The humans are forced to retreat and wait for the next attack, thinking that it will be their last stand. Near the Machine City, Neo and Trinity are greeted by thousands of missiles which Neo attempts to destroy, but is overwhelmed by their numbers. The Logos is attacked by the Sentinels forcing them to fly above the missiles for a few seconds. They breach the cloud layer and see Earth's real sky, to which Trinity whispers the word "Beautiful". Upon descent, they lose control causing them to crash the Logos into the Machine City. The crash kills Trinity. Neo enters the Machine City and encounters "Deus Ex Machina", the machine leader. Neo, warning that Smith plans to conquer both the Matrix and the real world, offers to stop Smith in exchange for peace with Zion. The machine leader agrees, and the Sentinels stop attacking Zion.
The Machines provide a connection for Neo to enter the Matrix. Inside, the Smith with the Oracle's powers steps forth, saying that he has foreseen his victory against Neo. After a protracted battle, Neo—finding himself unable to defeat Smith—allows himself to be assimilated. The machine leader sends a surge of energy into Neo's body in the real world. Because Neo is connected to the Source, the energy surge causes the Neo-Smith clone and all other Smith clones in the Matrix to be destroyed; deleting Smith once and for all, though Neo's life is sacrificed in the process. The Sentinels withdraw from Zion, Morpheus and Niobe embrace, and Neo's body is carried away by the machines. The Matrix is rebooted, and the Architect encounters the Oracle in a park. They agree that the peace will last "as long as it can", and that all humans will be offered the opportunity to leave the Matrix. When questioned about Neo's fate, the Oracle tells Sati that she thinks they will see Neo again as Sati reveals she created a beautiful sunrise over the horizon in Neo's honor. Seraph asks the Oracle if she knew this would happen; she replies that she did not know, but she believed.