The Battle of Autobot City refers to the protracted battle between the Autobots and Decepticons at Autobot City, the base of the Autobots on Earth, taking place in the year 2005 in one reality. By its end the leaders of both the Autobot and Decepticon forces were dead or dying, numerous combatants on both sides had been killed, and events were set in motion that would lead to the creation of Galvatron and, eventually, the passing of the Matrix of Leadership.
The Decepticons had succeeded in driving the Autobot army off Cybertron. However, the Autobots retained staging grounds on Cyberton's two moons and were in the final phase of preparations for their counterassault. All that remained was the transport of a final shipment of Energon cubes from Autobot City's production facilities. A shuttle was dispatched to Earth for this purpose.
Unfortunately for the Autobots, the Decepticon spy Laserbeak got wind of the Autobots' plans and warned Megatron, ruler of the Decepticons. In a move reminiscent of the Decepticons' boarding of the Ark on their initial arrival on Earth, Megatron led a sizeable contingent of Decepticons against the small Autobot crew on the shuttle. Heavily outnumbered and outmatched, the Autobots were overwhelmed. Ratchet, Ironhide, Prowl and Brawn all perished (or at least were deactivated) in this attack at the hands of Megatron and Starscream.
Having taken control of the shuttle, Megatron's plan became clear: the shuttle was to be used as the perfect Trojan horse and convey the Decepticons for a surprise attack on Autobot City itself, which Megatron seemed to think would vanquish the Autobots forever. On the other hand, Megatron was never really known for his tactical genius.
Megatron had calculated correctly in that the Autobot shuttle did not set off Autobot City's automated defences even if carrying a Decepticon crew. It was sheer chance that a small human child noted there was a hole in the shuttle and alerted the young Autobot Hot Rod, who divined the truth of the situation. Having said that, Hot Rod wasn't exactly one for tactical acumen either, deciding to open fire on the shuttle alone and some distance away from Autobot City, rather than bother to tell anybody what was going on first.
At any rate, with the Decepticons' cover blown, Megatron ordered the Decepticons to debark and attack immediately. A number of Decepticons transformed to alternate mode and commenced attacks on Autobot City and attempted to pick off those Autobots caught outside the city.
The Autobots, though surprised, quickly rallied to the defensive. Ultra Magnus, commanding the City, ordered Blaster to contact Optimus Prime on Cybertron's moon to obtain reinforcements, Springer to transform Autobot City into its defensive mode, and the only Autobot with an amphetamine problem to assist in alerting Autobots as to the attack (if they weren't already clued in by hordes of Decepticons bringing the rain right down on their heads.)
Blaster did manage to make brief contact with the Cybertronian Autobots, but the signal was cut off by the intervention of Soundwave and the four henchmen he had with him: Rumble, Ravage, Frenzy and Ratbat. However, Blaster evened the odds by putting his own quartet of counterparts into the fight.
Meanwhile, waiting as long as he possibly could to try and allow Hot Rod and Kup to get back inside the city, Springer activated Autobot City's defensive mode, causing the city to become an armoured fortress which had a much greater capability to hold off the Decepticon assault. It is not clear why Springer did not choose to activate Metroplex who by some accounts was the living core of Autobot City, but in any event the move was effective. It also had the added bonus of taking off the Decepticon Starscream's right foot.
Unable to penetrate Autobot City's defences by conventional means, Megatron then ordered the Constructicons to merge into the gestalt Devastator (G1). The giant robot quickly made his presence felt, shattering one attempt by Springer, Kup and Arcee to put him out of action. But even so the two sides were so evenly matched that the battle drew out over the course of the remainder of the day and through the night.
Eventually, though, the next morning brought the breaking of the Autobot defences and the possibility of a mass slaughter. It was at this crucial point that Autbot reinforcements commanded by Optimus Prime arrived. The Dinobots were deployed to attack Devastator, with only mild success, and did not stop the Decepticon advance into Autobot City.
That task fell to Optimus Prime, who decided it'd be a good idea to abandon a few million years' worth of tactical wisdom and make a frontal assault against the massed firepower of a Decepticon assault force. But it worked. In vehicular mode and later in robot mode, he singlehandedly scattered the Decepticon attack, fighting his way to engage Megatron in hand-to-hand combat.
The battle between the two leaders was brief and intense, but resulted in a seeming-victory for Prime. Only the foolishness of Hot Rod changed that result and let Megatron get the drop on the Autobots' greatest leader. Megatron inflicted what would be a fatal wound on Optimus Prime, only to be repaid with a haymaker that put Megatron off a ledge and into a fall that would prove almost-lethal.
The Decepticons seeing their leader conclusively defeated in this way broke their spirit. Starscream, taking interim command, ordered Astrotrain to transform and ferry the Decepticons away in a general retreat. Gathering up their wounded, the Decepticons fled, leaving the Autobots to similarly gather up their own casualties.
Large numbers of Autobots and Decepticons had either been terminated or wounded as a result of the battle. The wounded Decepticons - including Megatron - were thrown out of Astrotain to lighten the load, where they would later be found by the Chaos-bringer Unicron and reshaped into Galvatron, Scourge, Cyclonus, and the Sweeps. Optimus Prime eventually succumbed to his wounds and perished, but not before passing the Matrix of Leadership to Ultra Magnus as his successor.