The Roman Republic ( ) was a form of government of Rome and the era of the classical Roman civilization when it was run through public representation of the Roman people. Beginning with the overthrow of the Roman Kingdom (traditionally dated to 509 BC) and ending in 27 BC with the establishment of the Roman Empire, Rome's control rapidly expanded during this period—from the city's immediate surroundings to hegemony over the entire Mediterranean world. Roman society under the Republic was primarily a cultural mix of Latin and Etruscan societies, as well as of Sabine, Oscan, and Greek cultural elements, which is especially visible in the Roman Pantheon. Its political organization developed, at around the same time as direct democracy in Ancient Greece, with collective and annual magistracies, overseen by a senate. The top magistrates were the two consuls, who had an extensive range of executive, legislative, judicial, military, and religious powers. Even though a small number of powerful families (called gentes) monopolised the main magistracies, the Roman Republic is generally considered one of the earliest examples of representative democracy. Roman institutions underwent considerable changes throughout the Republic to adapt to the difficulties it faced, such as the creation of promagistracies to rule its conquered provinces, or the composition of the senate. Unlike the Pax Romana of the Roman Empire, the Republic was in a state of quasi-perpetual war throughout its existence. Its first enemies were its Latin and Etruscan neighbours as well as the Gauls, who even sacked the city in 387 BC. The Republic nonetheless demonstrated extreme resilience and always managed to overcome its losses, however catastrophic. After the Gallic Sack, Rome conquered the whole Italian peninsula in a century, which turned the Republic into a major power in the Mediterranean. The Republic's greatest strategic rival was Carthage, against which it waged three wars. The Punic general Hannibal famously invaded Italy by crossing the Alps and inflicted on Rome three devastating defeats at Trebia, Lake Trasimene and Cannae, but the Republic once again recovered and won the war thanks to Scipio Africanus at the Battle of Zama in 202 BC. With Carthage defeated, Rome became the dominant power of the ancient Mediterranean world. It then embarked on a long series of difficult conquests, after having notably defeated Philip V and Perseus of Macedon, Antiochus III of the Seleucid Empire, the Lusitanian Viriathus, the Numidian Jugurtha, the Pontic king Mithridates