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: