The Medes were a people from the current north of Iran who came to control a large area of territory that included Mesopotamia and the eastern Anatolian peninsula. From the birth of the Medo kingdom around the year 678 B.C. they were always vassals of the Neo-Assyrian Empire. But that ended between 616 and 605 BC. when, allied with Babylonians, Scythians and Cimmerians, they attacked the Assyrians erasing them from history.
From there began an expansion that, by 579 B.C. it led them to clash with the Lydians in Asia Minor. 30 years later the Median Empire would be conquered by the Achaemenid Cyrus the Great, who rebelled against his grandfather, the Median king Astyages, in 549 BC. The Lydians, for their part, had a longer history, since the kingdom had been established around 1300 BC, after the fall of the Hittite Empire. Settled in western Anatolia and on the Ionian coast, many historians consider them to be a Greek people, or at least highly Hellenized.
But during the war between the two, a significant episode occurred, not only for history but also for science. They had already been locked in the conflict for 5 years when the Lydian and Medo armies met in the Battle of the Halis River (current Kizilirmak), in Eastern Anatolia.
Herodotus tells that at the head of the Lydians was their king Aliates, while the Medes were led by theirs, Ciáxares. The battle dragged on and victory did not go to either side when, a few hours after noon, the sky suddenly darkened and the day turned into night.
Although Herodotus does not explicitly say that it was an eclipse, he does affirm that it had been predicted by Thales of Miletus, although evidently neither the Lydians nor the Medes had received the news. Assuming that, almost certainly, it was an eclipse, historians have been able to establish the exact date of the battle, thanks to astronomical calculations that place the phenomenon on May 28, 585 BC.
The contenders were so surprised, perhaps frightened, that, interpreting it as a divine sign, they immediately laid down their arms and negotiated a peace agreement.
Not only that, as part of the treaty the marriage of the daughter of the Lydian king, Aryénis, with the son of the Median king, Astyages (the grandfather of Cyrus), was agreed, and the river Halis was established as a permanent border between the two kingdoms.
As for the eclipse, if it was indeed predicted by the philosopher Thales of Miletus, it would be the oldest on record whose date was exactly determined in advance. This is also indicated, among others, by Cicero and Pliny the Elder. Diogenes Laertius tells that Xenophanes, who was a contemporary of Thales, was impressed by the prediction, as were Democritus and Heraclitus.
But this is not entirely clear. Some researchers question the veracity of Thales' prediction, stating that the astronomical knowledge of the time would not have been sufficient for it. And even that solar eclipses were caused by the interposition of the Moon was not discovered until a century later (by Anaxagoras or Empedocles).
In that case, what Herodotus may be describing would not be a solar eclipse, but a lunar one that would have occurred in the early hours of dusk. If both armies were confident that there would be a full moon as in the days immediately before, its concealment would have been equally shocking. According to this hypothesis, the date of the battle could have been July 4, 587 BC. or September 3, 609 BC, both days on which there were lunar eclipses.
In order to predict a solar eclipse, Tales would have had to know and use a saros cycle (the period of 223 moons after which the Moon and the Earth return to approximately the same orbital position, and therefore eclipses can be repeated) or have extensive knowledge of Babylonian astronomy.
The oldest known record of these cycles was found in Babylon, due to Chaldean astronomers (626-530 BC), who already knew that eclipses follow an 18-year cycle. However, Eusebius of Caesarea claims that the discoverer of the saros cycles was the Chaldean Berosus, who lived between 350 and 270 BC. Interestingly, by the year 87 B.C. the mechanical calculation of saros cycles it was already implemented in the Antikythera Mechanism.
However, there are no documentary records of the method that Thales could follow to make the prediction of him, and all modern attempts to reconstruct it have failed.