The relevant scripture is 2 Chronicles 35:20-24
The Egyptian army was on its way to fight alongside the
Assyrians against the Babylonians (2Kings 23:29). Josiah went out
to fight against Necho king of Egypt to stop him passing through
Josiah's land.
The battle was at Carchemish near the Euphrates. Although he
disguised himself, Josiah was killed in the battle.