Molybdenum disulfide (MoS) is a well-known and effective lubricant that provides extremely low values of coefficient of friction. It is known that the sliding process may induce structural transformations of amorphous or disordered MoS to the crystalline phase with basal planes oriented parallel to the sliding direction, which is optimal for reducing friction. However, the key reaction parameters and conditions promoting this structural transformation are still largely unknown. We investigate, by employing reactive molecular dynamics simulations, the formation of MoS layers from an amorphous phase as a function of temperature, initial sample density, and sliding velocity. We show that the formation of ordered crystalline structures can be explained in the framework of classical nucleation theory as it predicts the conditions for their nucleation and growth. These results may have important implications in the fields of coating and thin-film deposition, tribology, and in all technological applications where a fast and effective structural transition to an ordered phase is needed.