It was the growth of Babylon under Nabopolassar and their alliance with the Medes that persuaded the Egyptian king *Psammetichus I of the Twenty-sixth Dynasty to side with Egypt's erstwhile enemy, *Assyria. The *Assyrian capital of Nineveh fell in 612 BC, and the contest continued unresolved for many years.
In 610 BC, *Necho II inherited the Egyptian throne and, according to Biblical tradition, he became Nabopolassar's main enemy when he set out to fight the Babylonians. *Necho II interfered in the politics of Syria/Palestine and fought against King Josiah of Judah, when he tried to intervene in the conflict by barring Necho's way past the walls of Megiddo. Josiah was killed and *Necho II finally placed a ruler of his own choice in charge at Jerusalem.
The Egyptains then defeated the Babylonians at sites on the Euphrates, south of Carchemish, but, according to the Babylonian Chronicle, Nabopolassar's son *Nebuchadrezzar inflicted a major defeat on the Egyptians at the Battle of Carchemish in 605 BC. The major force withdrew, but the Babylonians pursued and destroyed the Egyptians in the district of Hamath, as they fled, bringing about a resounding victory for the Babylonians; ultimately, they seized all Egypt's northern possessions. A couple of months after this great Babylonian victory, Nabopolassar died and *Nebuchadrezzar inherited his empire.
BIBL. Wiseman, D.J. Chronicles of Chaldaean Kings. London: 1956 pp 5 ff.
Biographical Dictionary of Ancient Egypt by Rosalie and Antony E. David
Ancient Egypt. A Reference Guide. EdwART. 2011.