Herein, hyper-crosslinked polystyrene nanospheres (HPSs) were synthesized via emulsion polymerization and Friedel-Crafts reaction utilizing styrene as the primary raw material. The multielement (F, N, S) co-doped carbon nanospheres with enriching microporous structures were synthesized using ionic liquid ([EMIM]NTf2) assisted carbonization of HPSs under 400 °C. The fabricated carbon nanospheres exhibit excellent dispersion stability as well as remarkable anti-friction and anti-wear properties. In comparison to pure 500SN, the friction coefficient of the multielement (F, N, S) co-doped carbon nanospheres is reduced to 0.108, resulting in 81.9 % reduction in wear volume. Furthermore, the friction coefficient shows minimal fluctuation under different frequency and temperature conditions, which is significantly lower by 21.4 % and 31.6 % respectively compared to 500SN, while exhibiting an improved carrying capacity of up to 550 N. Through Raman spectroscopy, XPS, as well as FIB-TEM analysis, the result revealed that tribochemical reactions occur between the active elements within the nanospheres and the friction pairs leading to the formation of the composite protective film (40–70 nm) composed mainly of the deposition film and the frictional chemical protective film, achieving superior frictional performance.