Achaemenid Persian rule in Anatolia ended with the conquests of Alexander the Great, defeating Darius III between 334 and 330 BCE. Alexander wrested control of the whole region from Persia in successive battles. After Alexander's death, his conquests were split amongst several of his trusted generals, but were under constant threat of invasion from both the Gauls and other powerful rulers in Pergamon, Pontus, and Egypt. The Seleucid Empire, the largest of Alexander's territories, and which included Anatolia, became involved in a disastrous war with Rome culminating in the battles of Thermopylae and Magnesia. The resulting Treaty of Apamea in (188 BC) saw the Seleucids retreat from Anatolia. The Kingdom of Pergamum and the Republic of Rhodes, Rome's allies in the war, were granted the former Seleucid lands in Anatolia.