The first railway in BiH was opened for traffic on the 24th or December 1872. It was a modern type of railway between Banja Luka and Dobrljin (101.6 kilometers) in the Municipality of Bosanski Novi.
This railway was built as part of the Istanbul main route which, according to Turkish plans, was supposed to connect Istanbul and Vienna.
After the Berlin Congress (1878), Austria-Hungary occupied BiH and immediately started with intensive construction of railroads. The occupation troops built railway following the route of their penetration into BiH to ensure the supply of troops. The construction of narrow railway from Bosanski Brod to Sarajevo started already in September 1878 . On the 10th of September 1878, in Derventa was founded the first Directorate of BH railways, called “Directorate of Royal Bosnian Railways”. The director was the Austro-Hungarian Major – engineer Johan Tomasek.
The staff of the Directorate, according to the available archives of Railways of the FBiH, consisted of seven Austro-Hungarian officers and military personnel, 30 civilian officials from Austria-Hungary and a number of other staff – strangers. Domestic workers were support staff.
The military administration ordered that the section from Bosanski Brod to Derventa must be completed in two months. From Romania, where was finished the narrow-gauge railway Timisoara – Orsava, were transferred locomotives and available wagons, possession of “Higel and Sagel” which will build the railway in BiH. These circumstances determined the future character of the railroads, which are narrow-gauge tracks of 0.76 meter. Railroad to Derventa was built by a total of 40 engineers and 4,000 workers.
Wanting to establish communication from the interior to the coast, the Monarchy of Austria-Hungary decided to build the Southern Railway. The first section of this line from Metkovic to Mostar was opened to traffic in June 1885.
As a branch of the main railway Doboj – Sarajevo, in 1886 was built railway Doboj – Simin Han (66.7 km) along Spreca River. This railway ensured export of quality coal and salt from the rich Tuzla basin.
That same year, the Railway Directorate was moved from Derventa to Sarajevo. Due to the low bandwidth of constructed railways, the construction of the Southern Railway from Mostar to Sarajevo, and the section of railway Mostar – Ostrozac was put into traffic in 1888, and the first train entered Konjic in the following year.