Abstract The study is mainly to develop a new type of hard nanocomposite films based on the AlB2-type WB2 (h-WB2) system by studying the influence of carbon contents on the microstructures, mechanical and tribological properties, and thermal stability of the WBC films. By increasing the C2H2 partial pressure (PC2H2), carbon atoms present in forms of solid solution h-WBxCy and amorphous carbide a-WC, a-WBxCy, a-C:H (polymeric carbon) successively. Consequently, two- or three-phase nanocomposite films with microstructures comprising of nanocrystalline grains embedded in an amorphous matrix have been developed. Films with the h-WBxCy/a-WC and h-WBxCy/a-WC/a-C:H (or h-WBxCy/a-WBxCy/a-WC/a-C:H) nanocomposite structure deposited at PC2H2 ≤ 0.01 Pa (14.9–26.4 at.% C) exhibit highest hardness about 45 GPa and lowest wear rate about 10− 8 mm3/mN. And the transformation temperature of the h-WB2 phase has been enhanced greatly from 700 to 1000 °C by slight C-doping due to the formation of the strong interfaces between the nanocrystalline and amorphous phase in the films deposited at PC2H2 = 0.008 Pa. Moreover, proper C content (less than 26.4 at.%) can refine the film structure and reduce the oxygen impurity content and thereby improve the film properties. The residual stress of the films changes from tensile to compressive stress with the introduction of carbon, and the value of compressive stress is closely related to the film structures.