In 1867 the Bavarian state began first investigating the possibility of a railway link from Plattling via Deggendorf, Regen und Zwiesel to the Bohemian border to provide transportation for the industries there. The Bavarian-Austrian state treaty of 21 June 1851 envisaged a junction with the Bohemian railway network at Eisenstein in addition to the existing connexions to Bohemia at Furth im Wald and Passau. The Pilsen–Priesen(–Komotau) railway was prepared to extend their Pilsen–Dux line as far as the border at Eisenstein.
On the initiative of several local people the Bavarian Eastern Railway Company (Bayerische Ostbahn) were given authority by the Bavarian concession of 25 November 1872 to build the railway line. As a result, the Ostbahn dropped plans under a previously granted concession of 3 August 1869 for the construction of a route from Straubing to Cham. Preparation for construction of the new line began as early as 1873. The search for a suitable route was extraordinarily difficult due to the steep climb from the Danube into the Bavarian Forest and the numerous valleys that had to be crossed. This promised to make the line expensive to build and not particularly profitable. On the other hand, with a better link from the new line from Plattling through the Isar valley to Munich there was the attraction of a lucrative connexion with Bohemia. In 1874 work started on its construction.
At Plattling station the line branched off northwards from the Regensburg–Passau main line to Deggendorf and crossed the Danube there. As a result, Plattling station was relocated to the west and a new facility erected. The privately operated 8.7 km long Deggendorf–Plattling goods line, which had been opened on 1 March 1866, was broken up. Its two 2/2 coupled tank locomotives, delivered in 1866 by Maffei with the names DEGGENDORF and BAYER. WALD, were taken over by the Royal Bavarian State Railways as Class D IIs, nos. 1176 and 1177. Both engines were retired in 1895.
For the ramp from Deggendorf (320 m or 1,050 ft AMSL) to the heights around Gotteszell (600 m or 1,969 ft AMSL), two options were investigated. One was a direct link via Hirschberg with an incline of 2%, the other was longer but clearly less steep with an incline of only 1.25%. In spite of its higher construction costs, the latter was chosen because, long term, it would offer more economical and faster operation utilising a double loop line between Oberkandelbach and Grafling and the tunnel at Ulrichsberg. The valleys along the line of the railway would be crossed on long bridges or long, high embankments.
The most important structures on the route:
At 48m, the Ohe bridge is the second highest railway bridge in Bavaria, just behind the Königswart bridge (height 50 m, length 279 m) at Wasserburg am Inn. On the state border the two railway companies built a very large station building at Bayerisch Eisenstein, the border running right through the middle of the building. The line was laid as a single track, but the route was prepared for two tracks. However it has remained single to the present day because the junction to the Mühldorf (Obb)–Plattling line, opened in 1875, and the Pilsting–Landshut link line, taken into service in 1880, did not bring the anticipated growth in traffic for the Waldbahn and across the border.
During the construction of the line, Bavaria decided to nationalise the Ostbahn in a law passed on 15 April 1875. This took place on 10 May 1875 and led to a merger with the Royal Bavarian State Railways on 1 January 1876. As a result, the Plattling–Deggendorf–Gotteszell–Regen–Zwiesel–Ludwigsthal route was taken into service by the Bavarian state railway on 16 September 1877. After the completion of the Deffernik bridge the entire 74.7 km long route to Eisenstein was opened on 15 November 1877.