When certain transition metal compounds are heated in hydrogen sulphide, films of metal sulphide with effective lubricating properties are formed on the surface. With only a small pressure of gas molybdenum compounds can be lubricated up to 700 $^\circ$C and tungsten compounds up to nearly 1000 $^\circ$C. The temperatures and pressures required for the formation of these films are determined, and the effect of repeated sliding on the friction is studied both in the presence of the gas and in a vacuum over a wide temperature range. Transmission electron microscopy enables the frictional properties of a film to be related directly to its chemical composition and to the orientation of both film and substrate before and after heating. It also explains why titanium compounds cannot be lubricated so well.