This Battle of Megiddo is recorded as having taken place in 609 BC with Necho II of Egypt leading his army to Carchemish to fight with his allies the Assyrians against the Babylonians at Carchemish in northern Syria. This required passing through territory controlled by the Kingdom of Judah and Necho requested permission from its king, Josiah. For unknown reasons this permission was not granted and a battle took place in which Josiah was killed. The battle is recorded in the Bible, 1 Esdras of the Apocrypha and told also by Josephus.
In his days Pharaoh Neco king of Egypt went up to the king of Assyria to the river Euphrates. King Josiah went to meet him; and Pharaoh Neco slew him at Megiddo, when he saw him. 30 And his servants carried him dead in a chariot from Megiddo, and brought him to Jerusalem, and buried him in his own tomb.
There is a longer account recorded later in II Chronicles 35:20-35.
After all this, when Josiah had set the temple in order, Neco king of Egypt came up to make war at Carchemish on the Euphrates, and Josiah went out to engage him. But Neco sent messengers to him, saying, “What have we to do with each other, O King of Judah? I am not coming against you today but against the house with which I am at war, and God has ordered me to hurry. Stop for your own sake from interfering with God who is with me, so that He will not destroy you.” However, Josiah would not turn away from him, but disguised himself in order to make war with him; nor did he listen to the words of Neco from the mouth of God, but came to make war on the plain of Megiddo. The archers shot King Josiah, and the king said to his servants, “Take me away, for I am badly wounded.” 24 So his servants took him out of the chariot and carried him in the second chariot which he had, and brought him to Jerusalem where he died and was buried in the tombs of his fathers. All Judah and Jerusalem mourned for Josiah. Then Jeremiah chanted a lament for Josiah. And all the male and female singers speak about Josiah in their lamentations to this day. And they made them an ordinance in Israel; behold, they are also written in the Lamentations.
The account in Esdras adds some minor details, with the basic difference between it and the earlier account in Chronicles being that Josiah is described only as being 'weak' at Meggido and asks to be taken back to Jerusalem, where he dies. Cline points out that this brings the story more in line with and earlier prophecy made by the prophetess Huldah (II Kings 22:15-20).
Seven centuries after Josiah's death, Josephus also wrote an account of the events. This contains more details about Josiah's movements on the battlefield which have been suggested come from documents now lost, but Cline suggests it is based on the biblical accounts and perhaps Joephus's own views.(Cline 2000:97)
Finally there is the suggestion that Herodotus records this battle and Egyptian campaign in his writings about the pharaoh Necho, that are included in his famous Histories:
Necos, then, stopped work on the canal and turned to war; some of his triremes were constructed by the northern sea, and some in the Arabian Gulf, by the coast of the Sea of Erythrias. The windlasses for beaching the ships can still be seen. He deployed these ships as needed, while he also engaged in a pitched battle at Magdolos with the Syrians, and conquered them; and after this he took Cadytis, which is a great city of Syria. He sent the clothes he had worn in these battles to Branchidae of Miletus and dedicated them to Apollo.''