Nicomedia (modern Izmit in Turkey) was founded by Nicomedes I of Bithynia at the head of the Gulf of Astacus which opens to the Propontis. The city was founded in 712/11 BC as a Megarian colony and, in early Antiquity, was called Astacus (lobster). After being destroyed by Lysimachus, it was rebuilt by Nicomedes I of Bithynia in 264 BC under the name of Nicomedia, and has ever since been one of the most important cities in northwestern Asia Minor. Hannibal came to Nicomedia in his final years and committed suicide in nearby Libyssa (Diliskelesi, Gebze). The historian Arrian was born there. Nicomedia was the metropolis of Bithynia under the Roman Empire, and Diocletian made it the eastern capital city of the Roman Empire in 286 when he introduced the Tetrarchy system. Nicomedia remained as the eastern (and most senior) capital of the Roman Empire until co-emperor Licinius was defeated by Constantine the Great at the Battle of Chrysopolis (Uskudar) in 324. Constantine mainly resided in Nicomedia as his interim capital city for the next six years, until in 330 he declared the nearby Byzantium (which was renamed Constantinople (present-day Istanbul) the new capital. Constantine died in a royal villa at the vicinity of Nicomedia in 337. Owing to its position at the convergence of the Asiatic roads leading to the new capital, Nicomedia retained its importance even after the foundation of Constantinople.
However, a major earthquake on 24 August 358 caused extensive devastation to Nicomedia and was followed by a fire which completed the catastrophe. Nicomedia was rebuilt, but on a smaller scale. In the sixth century under Emperor Justinian the city was extended with new public buildings. Situated on the roads leading to the capital, the city remained a major military center, playing an important role in the Byzantine campaigns against the Caliphate.
From the 840s on, Nicomedia was the capital of the thema of the Optimatoi. By that time, most of the old, seawards city had been abandoned and is described by the Arab geographer Ibn Khurdadhbeh as lying in ruins. The settlement had obviously been restricted to the hilltop citadel. In the 1080s, the city served as the main military base for Alexios I Komnenos in his campaigns against the Seljuk Turks, and the First and Second Crusades both encamped there. The city was held by the Latin Empire between 1204 and ca. 1240, when it was recovered by John III Vatatzes. It remained in Byzantine control for a further century, but following the Byzantine defeat at the Battle of Bapheus in 1302, it was threatened by the rising Ottoman beylik. The city was twice blockaded by the Ottomans (in 1304 and 1330) before finally succumbing in 1337.