In 390 (or 387) BCE, Rome was just another city state vying for dominance on the Italian peninsula with the Etruscans, Samnites, Latins, Greeks, and Gauls, the Roman name for Celts. In July, a large Gallic warband rapidly descended on the near defenseless city of Rome. Previously, whenever the Gauls struck they looted on their way and this gave time to raise the legions, which at this time were only used for specific campaigns then disbanded. (Also, the Severian Wall which ringed Rome at its height wouldn’t be built for another hundred years.) However this time, the Gauls did not loot and drove straight to the city. The Romans couldn’t raise and train the legions, but every citizen was part of the militia, and expected to arm and armour themselves.
On 18 July, 390 BCE, 25,000 Roman citizens lined up against 15,000 Gauls at Allia outside of Rome. In this period of Roman history, the Romans were armed and organized in the Greek hoplite style (a phalanx of spears and shields) with the richest citizens (and thus best equipped) in the center, and the poorer and less well equipped to the flanks. Phalanxes are devastatingly powerful to the front but are not very maneuverable, and furthermore, vulnerable to the side. The Gauls ignored the center and chose to attack the less well equipped phalanxes on the flanks. The fast moving sword and shield equipped Gauls quickly defeated both sides before the center could react. This broke the Roman army. What was left of it retreated to the nearby walled town of Veii, recently captured from the Etruscans, while the Gauls sacked Rome for a week or so. A small Roman army that was on campaign against the Latins to the south eventually forced the Gauls, heavily laden with slaves and loot and unwilling to fight another battle, back north.
The Battle of Allia forced a decision upon the Romans: should they move their capital to Veii, with its walls, and adopt a generally defensive posture in central Italy? Or should they reform their army and go on the offensive to protect their city? Livy suggests that the Veii option was the favorite, and had they taken it there would have been no Roman conquests as we know them.
Instead, the Romans reformed their army, and made the first steps toward the legionary system we are familiar with today. First, they professionalized part of their army and maintained it throughout the year. Also, the remaining hoplite armed legionnaires formed the reserve, which allowed them time to maneuver into position to use their stabbing spears to great effect. These were the usually the richest and oldest citizens and eventually became the “triarii”. The rest of the army over time adopted the Gallic sword and shield to fight with, increasing their maneuverability, and eventually used their spears to throw. Inevitably, the younger and keener citizens moved to the front and the older and wiser ones to the rear, but this wasn’t formalized into the “hastatii” and “princips” until the First Samnite War thirty years later. The three lines of the hastatii, princips, and triarii formed the basis of the manipular legions with which the Roman Republic conquered most of the Mediterranean basin. The manipular legion was the standard Roman formation until the Marian Reforms 300 years later.
Rome wasn’t sacked again for another 800 years (until 410 CE by the Visigoths under Alaric).