If we have to give these bastards our lives,...WE GIVE 'EM HELL BEFORE WE DO.”
― Captain Mifune[src]
The Battle of Zion was the climax of the perennial First Machine war.
Before the battle occurred it was no secret the Machines intended to destroy Zion. The rebel ship Osiris sent a last wave of data scans before contact was lost and the Osiris destroyed. This information was enough for the rebels to confirm that the Machines had assembled an army: 250,000 Sentinels strong and a large number of Diggers which were drilling straight to Zion.
Commander Jason Lock, commander-in-chief of Zion's defenses theorized that the Sentinels would cut off the main lines in and out of Zion because they would be vulnerable to counter-attack if they were left alone. So, before the Machines could get into position, Lock ordered around six ships including the Logos and the Mjolnir to counter-attack the Machines with EMP blasts.
However, Bane, whose body was inhabited by Smith, triggered an EMP before the ships could get into position. Five ships including Bane's went down instantly with a massive power failure. The Machines broke through into the main lines and slaughtered almost everyone in the ships. Only the Mjolnir managed to elude the Machines and afterwards made a pass for survivors. Only one was found — Bane.
Subsequently, Lock called for additional volunteers to hold the Dock and make additional weaponry to destroy the Diggers, the most strategic course of action. The Mjolnir made a pass over the Logos and found the Logos' crew, and in turn managed to re-activate the ship using a power transfer. After Neo awoke from his coma, he told the crews that he needed to take a ship, planning to go to the Machine City in order to reason with the Machine mainframe, though he did not tell them this.
Many were skeptical but Niobe, captain of the Logos told Neo that he could take her ship. It was during this time that the Machines drilled into the walls of Zion's Dock.
The APU Corps and around 5,000 Infantry had been assembled in the Dock to try and hold off the Machines. Captain Mifune, in command of the Dock's defense systems, delivered a morale-rallying speech before the Diggers drilled through the walls and crashed into the landing pads. Moments later thousands of Sentinels poured out through the opening to be met with massive gunfire from the APU's. Dual machine guns on each APU gave the defenders a formidable advantage in terms of firepower.
Besides the APUs, the Dock Control also had machine guns mounted all over the sides and were frantically firing into the Sentinels. It was at this time that Niobe began piloting the Mjolnir home through a mechanical line, deemed impossible even by her lover Jason Lock because they were so compacted. Despite taking heavy damage, the Mjolnir's gunnery systems destroyed hundreds of pursuing Sentinels.
Zion Control estimated it would take 12 minutes to reach Gate 3. The battle now was looking hopeless, as the primary Dock center had been destroyed by a huge swarm of Machines and tens of thousands of Sentinels were inside the Dock. The Infantry forces with dual barreled bazookas managed to temporarily disable one of the Diggers, adding much to the morale of the Zion defenses.
However another Digger crashed into the Dock, allowing thousands more Sentinels to pour into the area, overwhelming the Dock Control and reducing Mifune's APU Corps to just thirteen operational units. Lock tried to contact Mifune, who was closest to Gate 3 to cut the links and open the gate, but his radio was non-functional. The Sentinels took out the remaining APU's, and reformed into a huge impenetrable force to destroy Mifune's APU.
Mifune stood his ground, fearless and destroyed many Sentinels before he was mauled to death by the Sentinel's claws. In Mifune's dying breath he told Kid to open Gate 3, which he did just in time. The Mjolnir smashed through the gate and Link activated the EMP, annihilating the first wave of Sentinels.
However Jason Lock protested this when the three Captains reported down to Zion Control saying that the EMP also took out every piece of defensive hardware there was, saying that the crews "incompetence" had handed the Machines the Dock on a silver platter. Lock ordered everyone to fall back to the Temple, where the fight was now looking hopeless. Lock's infantry began fortifying the entrance with enough mounted weapons and artillery to make their last stand.
Although Trinity had been killed when the Logos crashed into the Machine City, Neo brokered a deal with the Deus Ex Machina: he would defeat the renegade program Smith if the Machines would bring an end to their war against the humans. The Machines accepted but Neo was defeated, and Smith copied himself into Neo. However, this gave the Deus Ex Machina a direct link to the Smith program and initiated a surge which wiped the coding for Smith clean from the Matrix, and restored it to normal.
In return, the Machines called off their war and the Deus Ex Machina ordered the Sentinels to return to the Machine City.
The end of the war via a peace treaty was the biggest breakthrough humanity had ever been given. The war was over, and Zion was saved by the actions of Neo and the Machines. Both Zion and the Matrix were allowed to continue their existence, with the promise that anyone inside of the Matrix who realized the 'truth' is allowed to be unplugged without Machine interference.
This suited both, as the Machines still needed humans for energy while Zion did not have the food-production resources to support the entire population - and even then, the majority of the human population was content with living in the false reality of the Matrix.