The Deggendorf Railway had already procured two four-coupled tank locomotives from 1866, which were used for shunting at large stations. Based on these, the Bavarian Eastern Railway procured five similar examples from the following year, which were significantly heavier. These were first designated as class D and later as D IV at the state railway and served as a model for the D IV of the state railway.
The latter was procured between 1875 and 1897, which is why it could later be found at almost every larger Bavarian station. During this time, changes were made in production, so the driver's cab, which was initially open at the back, was closed in later series. Like many other light tank locomotives, the D IV had external Stephenson valve gear and a water tank inside the frame. It was the first Bavarian locomotive with this arrangement of the water tank and thus became the model for many others.
A total of 46 of this type were manufactured by Maffei and 86 by Krauss. The Pfalzbahn had another 31 almost identical locomotives made by the same manufacturers and designated them as T 1. In 1925, a total of 122 remaining machines were assigned to the 8871-72 series. They were phased out by the early 1930s.