Towards the end of the 11th c. BC Doric tribes from Argolis settled in Megaris and built the first villages. Much later, five villages merged to found Megara. The oldest finds go back to the 8th c. BC, and the first border clashes with neighbouring Corinth started at around the end of the century. The first colony was founded in Sicily (Megara Hyblaea, 728 BC) at about the same time, and this was followed by other colonies in the next century in Propontis, the most important being Byzantium (660 BC). Ca. 600 BC Megara came under the rule of the tyrant Theagenes. The expansion of Athens in the 6th c. BC created serious problems for the city, which resulted in the loss of Salamis and Nisaea. In the 2nd half of the same century Megara's prosperity, which arose from its flourishing industry, stockfarming and trade generally, was also reflected in its architecture with the construction of many public buildings. The important figures in this period were the engineer Eupalinos and the poet Theognis, at this time when severe social upheavals were occurring.
During the Persian Wars Megarian ships took part in the naval battle of Salamis and Megarian hoplites in the Battle of Plataea. A few years later a war between Megara and Corinth broke out (460 BC) and the Megarians were forced to ally themselves with Athens.
The Megarian Decree (432 BC), which excluded Megarian ships from every commercial harbour controlled by the Athenian state, was one of the causes of the Peloponnesian War, in the course of which the Megarians suffered terrible hardships.
In the 4th c. BC, in spite of the fact that the city was occasionally embroiled in wars and disputes with Corinth in 395 BC, with Athens over the sacred earth (orgas) shortly before 350 BC and with Philip II in 339 BC, Megara followed a pacific policy which contributed to the expansion of its economy. For the first time the city struck its own silver coin with symbols Apollo'd head and a lyre. Along with the great building activity, public places and sanctuaries were embellished with works by the great sculptors of the period, as well as the philosopers Eucleides and Stilpon of the Philosophical School of Megara, were active at this time. The capture of the city by Demetrios Poliorcetes in 307 BC and the seizure of its numerous slaves were a great blow to the economy. During the Hellenistic period Megara entered the Achaean and Boeotian League, In 146 BC it was taken by the Romans, who destroyed it in 45 BC. The 2nd c. AD brought a new period of growth and prosperity, especially under the emperor Hadrian, when many public works were carried out. Politically Megara belonged to Boeotia until 395 AD, when it was definitely destroyed by the Goths.