The Bavarian Class D XI engines were branch line (Lokalbahn) saturated steam locomotives built for service with the Royal Bavarian State Railways (Königlich Bayerische Staatsbahn).
The state railway procured 139 examples between 1895 and 1912; it was the most numerous Bavarian branch line locomotive. Both Krauss and Maffei supplied three prototypes each and both were later involved in the production batches.
Eight locomotives of the same type were supplied by Krauss in 1900 to the Lokalbahn AG (Lokalbahn Aktien-Gesellschaft or LAG), which later sold them to the Bavarian state railway, where they were given the numbers 2507 to 2512. A further three locomotives were supplied by Krauss to the South German Electric Branch Lines (AG Süddeutsche elektrische Lokalbahnen) that was taken over in 1904 by the LAG; again these locomotives were sold to the state railway. They were given the numbers 2762–2764. These machines were designated as Class PtL 3/4 under the new classification scheme, but did not differ significantly from the newer Class D XI engines. Another five PtL 3/4 were procured by the state railway in 1914 and given the numbers 2783–2787.
Three of these locomotives were also produced for the Palatinate Railway (Pfalzbahn) as the T 4.II, but these had different dimensions, including smaller driving and carrying wheels.
The Deutsche Reichsbahn took over all 147 vehicles in 1925 as the DRG Class 98.4-5. The D XI engines were given the numbers 98 411–556 and the PtL 3/4 machines the numbers 98 561–568. About half the locomotives were retired between 1931 and 1933.
Two machines remained after the Second World War in Czechoslovakia and four in Austria. The last were numbers 98 500, 514, 546 und 549, which were given the numbers 791.01–04 by the Austrian Federal Railway (Österreichische Bundesbahn or ÖBB). They were taken out of service in 1957.
The Deutsche Bundesbahn took over 56 engines in 1945. The last loco was taken out of service in 1960 in Nuremberg and transferred to Ingolstadt. There it was set up as a memorial in front of the station in 1968.