The subject is taken from 2 Chronicles 35, which records that 'Neco king of Egypt came up to fight against Carchemish by Euphrates: and Josiah went out against him. But he sent ambassadors to him, saying, What have I to do with thee, thou king of Judah? I come not against thee this day, but against the house wherewith I have war: for God commanded me to make haste: forbear thee from meddling with God, who is with me, that he destroy thee not. Nevertheless Josiah would not turn his face from him, but disguised himself, that he might fight with him, and hearkened not unto the words of Neco from the mouth of God, and came to fight in the valley of Megiddo. And the archers shot at king Josiah; and the king said to his servants, Have me away; for I am sore wounded. His servants therefore took him out of that chariot, and put him in the second chariot that he had; and they brought him to Jerusalem, and he died, and was buried in one of the sepulchres of his fathers. And all Judah and Jerusalem mourned for Josiah.'
The historical events of the death of Josiah involve the power struggle between Babylon and Egypt in the end of the seventh century BC. and precipitated the collapse of the kingdom of Judah and the Hebrew exile in Babylon. Pharaoh Neco (Wehimbre Necho) came to power in Egypt in circa 610BC; by 609 he had already captured both Gaza and Ashkelon in Canaan on the borders of the Kingdom of Judah, and was threatening Judah. However, Egypt was itself increasingly concerned about the rising kingdom of Babylon which had captured the Assyrian Empire's capital, Nineveh, in 612BC and was agressively expanding across towards Harran, where the new (and last) King Assuruballit II of Assyria was established. In order to check Babylon, Neco in 609BC marched north through Judah (the shortest route) to Assuruballit's aid; it was during that march that Josiah decided to attack the Egyptians at Megiddo, suffering a heavy defeat as well as losing his own life. Partly as a result of this delay, Neco failed in his attempt to aid Assuruballit, although he did assert some sort of continued influence at Carchemish, an Egyptian stronghold on the Upper Euphrates. On his return to Egypt three months later, Neco invaded Judah (probably to ensure that access to Carchemish would in future be unimpeded), deposing Josiah's son, King Jehoahaz, and reducing Judah to a vassal kingdom under another of Josiah's sons, Jehoiakim.
In 605BC, the Babylonian King Nabopolassar, sent an army against Egypt under the command of his son, Nebuchadnezzar. The latter succeeded in capturing Carchemish and pursued the fleeing Egyptian forces to the district of Hamath where he crushed them completely. Continuing on towards Egypt, he accepted on his way the surrender of Judah, but was subsequently halted by the news that his father had died, forcing him home to secure the throne before returning to organise the newly conquered territories. In 601BC, however, Nebuchadnezzar suffered a defeat at the hand of the Egyptians that persuaded King Jehoiakim to withold the annual tribute to Babylon in the belief that the balance of power had swayed in Egypt's favour. In consequence, Nebuchadnezzar sent his armies against Judah in 597BC; Jehoiakim died before Nebuchadnezzar arrived and his son, Jehoiachin, was on the throne when the Babylonians took Jerusalem in March of that year. Jehoiachin was sent to Babylon with 10,000 of his most distinguished citizens and Jehoiachin's uncle, Zedekiah, was made King of Judah in his place. When the new king several years later rebelled against Nebuchadnezzar, the Babylonians returned and recaptured Jerusalem in the summer of 586BC, destroying the city and deporting the majority of the remaining population to Babylon.