Bakhmach was first mentioned in 1147 in the Hypatian Codex. Rapid development began in the 1860s and 1870s when the Libau–Romny Railway line nearby was under construction. The Battle of Bakhmach (Bitva u Bachmače in Czech) was fought between the Czech legion in Russia and German forces occupying Ukraine. Following a Legion victory the Germans negotiated a truce. In January 1919, the city was the site of battles between the invading Bolsheviks forces and the Chornomorska Division, which was attempting to keep the Left-bank Ukraine under the control of the army of the Ukrainian National Republic (UNR). During World War II, Bakhmach was under German occupation from 13 September 1941 and was liberated 9 September 1943 by the 75th Guards Rifle Division.