In this study, a novel Ni-P-AlN-WS2 nanocomposite coating has been successfully prepared on AZ31 alloy substrate by electroless co-deposition process. The effect of nanoWS2 concentration in the plating bath on the surface morphology, microhardness, friction coefficient and wear behavior of the composite coatings have been investigated. The results showed that the Ni-P-AlN-WS2 nanocomposite coatings had a fine nodular structure and AlN and WS2 nanoparticles were uniformly dispersed in the composite coatings. The Ni-P-AlN nanocomposite exhibited the highest hardness of 810 HV200, which is 291 higher than that of conventional Ni-P coating. The incorporation of WS2 nanoparticles in the Ni-P-AlN nanocomposite coatings reduced the hardness of Ni-P-AlN-WS2 nanocomposite coatings, which is 702 HV200 at 1.5 g l−1 nanoWS2 concentrations in the bath and the hardness decreased with the increase of nanoWS2 concentration in the bath. However, the incorporation of WS2 nanoparticles in the Ni-P-AlN nanocomposite coatings significantly decreased the friction coefficient and improved wear resistance of Ni-P-AlN-WS2 nanocomposite coatings. It indicated that Ni-P-AlN-WS2 nanocomposite coatings exhibited both lower friction coefficient and higher wear resistance at the same time.