SM31 class had been designed for shunting heavy freight trains in large freight stations, works and harbours. The design was elaborated in Fablok in 1973, mainly on the basis of SM42 locomotive. Production of this series lasted between 1976 and 1981, as well as between 1983 and 1985. In this period PKP bought 167 items of this series machines. A total number of ca. 200 locomotives was produced, with the rest of them servicing Polish industry, chiefly mining. Also first two prototypes (SM31-001 and SM31-002) were sold to industrial works, and the last one locomotive for PKP was re-bought from the industry (SM31-170).