In the early twenties, the Polish PKP ordered Hanomag to design an improved variant of the Prussian P 8. Hanomag built the first five in 1923, which were designated Ok22 due to their year of design. Compared to the P 8, they had a more powerful boiler that was mounted higher and they had electric lighting. Production was only continued in Poland between 1928 and 1934 and resulted in 185 more locomotives.
At the beginning of World War II, one came to Lithuania and was designated K9 by the LG. Soon a considerable number of 130 was taken over by the Reichsbahn and numbered 38 4501 to 38 4630. During the war, the Soviet Union captured 78 and rebuilt most of these to broad gauge. After the war, the PKP only had 57 at their disposal, of which the last ones were used until 1979. Today only two are still existing of which none is still operational. Ok22-23 is located at Jaworzyna Śląska and Ok22-31 at Wolsztyn.