The first railway in Azerbaijan opened in 1880 between the capital, Bakı (Baku) and the settlement of Imeni Kirova (present day Suraxanı, now a suburb of Bakı). It was followed in 1883 by a line from Bakı to Tiflis (present day Tbilisi, Georgia). Because Azerbaijan was then part of the Russian Empire, it was natural that the new railways should be constructed to the Russian standard gauge of 1524mm (later revised to 1520mm), even though there was at that time no rail connection with Russia. Further railway development was at the same gauge, almost 3000km of line being constructed under the Russian Empire and the Soviet Union.
Following the dissolution of the Soviet Union, conflict in the region caused considerable changes to the railways of Azerbaijan. The borders with Armenia are closed, and all through rail services discontinued. There are no railways currently operating in de facto independent Nagorno-Karabakh, nor in the Armenian occupied corridor between Armenia and Nagorno-Karabakh. The Naxçivan enclave is isolated from the rest of the country, although it is believed that some trains still operate there and that the international connection with Iran remains open. The main part of the country retains its rail links with Georgia and Russia.
A new international link between Astara and the city of the same name in Iran opened in 2016. It is constructed to dual (1520mm and 1435mm) gauge and will eventually link with the remainder of the Iranian network, allowing through traffic to resume without passing through Armenian territory.