The foundation of the railway in Azerbaijan was laid in 1878 and its construction was completed on January 20, 1880. It consisted of the Baku-Sabunchu-Surakhani railway with a length of only 20 km. Starting from that historical period, Azerbaijan has developed and improved, taking into account the increased demand for rail freight. At present, the total length of the main roads is 2910.1 km, the length of operation is 2079.3 km, of which 802.3 km is double. 1241.4 km or 59.7% of the total length of the road is electrified, 837.9 km - ie 40.3% - with the relay line. It is equipped with an automated signaling system of 1527.7 km.
The first railroad construction and subsequent development in Azerbaijan was due to the direct transportation of oil. The existence of oil in Absheron was known from ancient times. Baku oil has been used for a long time in a systematic manner and has been used for illumination and treatment mainly in Azerbaijan, its Middle East and Central Asia, Russia and India.
The first drilling well was developed in 1847, the further development of oil extraction, especially due to the abolition of the shopping system in the early 70s of the 19th century, oil extraction was sharply increased. In the conditions of increasing oil production, the issue of improving oil transportation has become an actual picture. Transportation of oil from the main oil fields (Sabunchu, Surakhany, Balakhani) to Baku oil refineries and the Caspian Sea to the central regions of Russia was carried out in a very primitive way, caravan method, wooden vats and bins, and their number reached 10,000.
Such a method was quite costly and a serious obstacle to the future development of oil business. The oil industry in Baku was extremely interested in the construction of railways and pipelines for more revenue. Thus, without exaggeration it can be said that the main cause of the railway construction in Baku and Azerbaijan was Baku oil and its industrial processing. They have repeatedly appealed to the Committee of Ministers on the construction of a railway between oil and gas refineries. Finally, their insistent demands give their fruits. At the meeting of the Committee of Ministers held on June 16, 1878, with the participation of Tsar II Aleksandr, the project on construction of the railway in the oil field is approved. 25, 2 verst-length railroad is being built in the "Poti-Tiflis" railroad society. The community takes over the construction of lines within one year and six months. The construction engineer is commissioned by Krubets. In the short time, the materials and equipment needed for construction are sent to Baku. In December 1878, Krubetsin wrote to the city administration that there is a great need for the construction of additional storage facilities in Black City.
One of the main tasks for the railway line was to quickly demolish Balakhani and Surakhani lanes. The city administration appoints the assessment of these lands to the public commission headed by philanthropist Haji Zeynalabdin Taghiyev. The Commission conducts research and evaluates the land privatized with more than 21 desyats in the amount of 34,580 rubles. In general, the construction costs of railway lines in the oil sector amounted to 784,872 rubles. The construction of the railway began in 1878 and expires in 1879. From Dec. 17, cargoes are being transported to Balakhani, Surakhany, Sabunchu stations. On January 20, 1880, the railway was officially opened. For the first time in the world, oil is being transported through cisterns.
The Republican Party and the Soviet organizations started the reconstruction work on the electrification of the Baku-Sabunchu railway. 21 days after the tramway was put into operation, on 29 February 1924, the Baku City Council decided: "To begin building the BAKI-SABUNCU-MARKAN-BUZOVNA electric train (Absheron suburban electric field) to ensure the connection with the districts of the city and its vineyards to be considered ". In March 1925, the reconstruction and elitization of the Baku-Sabunchu railway began. The total work was completed in 14.5 months. On July 26, 1926, the first electric trains to Absheron's famous oil regions, Sabunchu and Surakhani, began to move.