Moving mechanical interfaces are commonly lubricated and separated by a combination of fluid films and solid ‘tribofilms’, which together ensure easy slippage and long wear life1. The efficacy of the fluid film is governed by the viscosity of the base oil in the lubricant; the efficacy of the solid tribofilm, which is produced as a result of sliding contact between moving parts, relies upon the effectiveness of the lubricant’s anti-wear additive (typically zinc dialkyldithiophosphate)2. Minimizing friction and wear continues to be a challenge, and recent efforts have focused on enhancing the anti-friction and anti-wear properties of lubricants by incorporating inorganic nanoparticles and ionic liquids3,4. Here, we describe thein operandoformation of carbon-based tribofilms via dissociative extraction from base-oil molecules on catalytically active, sliding nanometre-scale crystalline surfaces, enabling base oils to provide not only the fluid but also the solid tribofilm. We study nanocrystalline catalytic coatings composed of nitrides of either molybdenum or vanadium, containing either copper or nickel catalysts, respectively. Structurally, the resulting tribofilms are similar to diamond-like carbon5. Ball-on-disk tests at contact pressures of 1.3 gigapascals reveal that these tribofilms nearly eliminate wear, and provide lower friction than tribofilms formed with zinc dialkyldithiophosphate. Reactive andab initiomolecular-dynamics simulations show that the catalytic action of the coatings facilitates dehydrogenation of linear olefins in the lubricating oil and random scission of their carbon–carbon backbones; the products recombine to nucleate and grow a compact, amorphous lubricating tribofilm.