Nabopolassar emerged as king of Babylon in 626 BC during a period of weakening Assyrian control. He fought a prolonged war to secure Babylonia and allied with the Medes against Assyria. The coalition captured Nineveh in 612 BC, and the remaining Assyrian forces were eventually driven from Harran. In his final years his son, crown prince Nebuchadnezzar, commanded Babylonian armies in the west. Nabopolassar died in 605 BC and was succeeded by Nebuchadnezzar II.