According to Pausanias, the Megarians said that their town owed its origin to Car, the son of Phoroneus, who built the citadel called 'Caria' and the temples of Demeter called Megara, from which the place derived its name.
In historical times, Megara was an early dependency of Corinth, in which capacity colonists from Megara founded Megara Hyblaea, a small polis north of Syracuse in Sicily. Megara then fought a war of independence with Corinth, and afterwards founded Chalcedon in 685 BC, as well as Byzantium (c. 667 BC).
Megara is known to have early ties with Miletos, in the region of Caria in Asia Minor. According to some scholars, they had built up a "colonisation alliance". In the 7th/6th century BCE these two cities acted in concordance with each other.
Both cities acted under the leadership and sanction of an Apollo oracle. Megara cooperated with that of Delphi. Miletos had her own oracle of Apollo Didymeus Milesios in Didyma. Also, there are many parallels in the political organisation of both cities.
In the late 7th century BC Theagenes established himself as tyrant of Megara by slaughtering the cattle of the rich to win over the poor. During the second Persian invasion of Greece (480–479 BC) Megara fought alongside the Spartans and Athenians at crucial battles such as Salamis and Plataea.
Megara's defection from the Spartan-dominated Peloponnesian League (c. 460 BC) became one of the causes of the First Peloponnesian War (460 – c. 445 BC). By the terms of the Thirty Years' Peace of 446–445 BC Megara was returned to the Peloponnesian League.
In the (second) Peloponnesian War (c. 431 – 404 BC), Megara was an ally of Sparta. The Megarian decree is considered to be one of several contributing "causes" of the Peloponnesian War. Athens issued the Megarian decree with the aim of choking out the Megarian economy. The decree banned Megarian merchants from territory controlled by Athens. The Athenians claimed that they were responding to the Megarians' desecration of the Hiera Orgas, a sacred precinct in the border region between the two states.
Arguably the most famous citizen of Megara in antiquity was Byzas, the legendary founder of Byzantium in the 7th century BC. The 6th century BC poet Theognis also came from Megara. In the early 4th century BC, Euclid of Megara founded the Megarian school of philosophy which flourished for about a century, and which became famous for the use of logic and dialectic.
In 243 BC Megara expelled its Macedonian garrison and joined the Achaean League, but in 223 BC the Megarians left the Achaeans and joined the Boeotian League.
The Megarians were proverbial for their generosity in building and endowing temples. Saint Jerome reports "There is a common saying about the Megarians [...:] 'They build as if they are to live forever; they live as if they are to die tomorrow.'"
Megara is located in the westernmost part of Attica, near the Megara Gulf, a bay of the Saronic Gulf. The coastal plain around Megara is referred to as Megaris, which is also the name of the ancient city state centered on Megara. Megara is 8 km west of Nea Peramos, 18 km west of Eleusis, 19 km east of Agioi Theodoroi, 34 km west of Athens and 37 km east of Corinth. The Motorway 8 connects it with Athens and Corinth. The Megara railway station is served by Proastiakos suburban trains to Athens and Kiato. There is a small military airfield south of the town, ICAO code LGMG.
The main town Megara had 23,456 inhabitants at the 2011 census. The largest other settlements in the municipal unit are Vlychada (pop. 1,462), Kineta (1,446), Pachi (542) and Lakka Kalogirou (517).
The municipality Megara was formed at the 2011 local government reform by the merger of the following 2 former municipalities, that became municipal units (constituent communities in brackets):Megara
The municipality has an area of 330.11 km2, the municipal unit 322.21 km2.Orsippus (8th century BC), runner
Byzas (7th century BC), founder of Byzantium
Theognis (6th century BC), elegiac poet
Eupalinos (6th century BC), engineer who built the Tunnel of Eupalinos on Samos
Theagenes (c. 600 BC), Tyrant of Megara
Euclid (c. 400 BC), founder of the Megarian school of philosophy
Stilpo (c. 325 BC), philosopher of the Megarian school
Teles (3rd century BC), cynic philosopher.
Mediumwave transmitter with a 180 metres tall radio mast, broadcasting on 666 kHz and 981 kHz