Lydia, or Maeonia as it was called before 687 BCE, was a major part of the history of western Anatolia, beginning with the Atyad dynasty, who first appeared around 1300 BCE. The succeeding dynasty, the Heraclids, managed to rule successively from 1185-687 BCE despite a growing presence of Greek influences along the Mediterranean coast. As Greek cities such as Smyrna, Colophon, and Ephesus rose, the Heraclids became weaker and weaker. The last king, Candaules, was murdered by his friend and lance-bearer named Gyges, and he took over as ruler. Gyges waged war against the intruding Greeks, and soon faced by a grave problem as the Cimmerians began to pillage outlying cities within the kingdom. It was this wave of attacks that led to the incorporation of the formerly independent Phrygia and its capital Gordium into the Lydian domain. It was until the successive rules of Sadyattes and Alyattes, ending in 560 BCE, that the attacks of the Cimmerians ended for good. Under the reign of the last Lydian king Croesus, Persia was invaded first at the Battle of Pteria ending without a victor. Progressing deeper into Persia, Croesus was thoroughly defeated in the Battle of Thymbra at the hands of the Persian Cyrus II in 546 BC.