In antiquity, the city was called Astacus or Olbia (founded 712 BC). After being destroyed, it was rebuilt and founded 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 (Gebze). The historian Arrian was born there. Nicomedia was the metropolis of Bithynia under the Roman Empire (see Nicaea), 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 Licinius was defeated by Constantine the Great 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 as Nova Roma, which eventually became known as Constantinople (present-day Istanbul). 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.
The city was conquered by the Ottoman Turks in 1338.
The earthquake of August 17, 1999 (magnitude 7.4) devastated the region, killing more than 19,000 people and leaving many more homeless. It took several years for the city to recover from this disaster; but the scars, especially on the memories of the residents - many of whom lost loved ones, can still be observed.