The electrochemical hydrogen evolution reaction (HER) has become one of effective ways to produce hydrogen. MoS2 is a promising electrocatalyst for the HER, and loading noble metal atoms on MoS2 support can further enhance its HER activity. In present work, the CO was employed as a structure-directing agent to in situ synthesize MoS2-n (n = 0, 0.5, 1.0, 1.4 and 2.0 MPa, representing the CO pressure). Among them, the MoS2-1.4 with highest amounts of sulfur vacancies and superior alkaline HER performance was selected as the support for Ru loadings. Sulfur vacancies can stabilize Ru nanoparticles, prevent nanoparticles from aggregating, and facilitate the formation of small-sized nanoparticles. By optimizing the loading amounts of Ru, the 5Ru@MoS2-1.4 with the Ru loading of 5 wt.% and nanoparticle size of 2 nm exhibits the best alkaline HER activity by displaying a low overpotential of 55 mV and Tafel slope of 68.6 mV dec−1 at a current density of 10 mA cm−2 in 1.0 M KOH medium. This can be majorly related to the synergistic effect of MoS2-1.4 support and small-sized Ru nanoparticles, wherein the CO plays a significant role in regulating the structure of MoS2-1.4 support that favors dispersion of Ru nanoparticles. Generally, present work provides a strategy to enhance the HER catalytic performance of MoS2, which is favorable for other highly-efficient catalyst design.