We have developed an effective strategy to synthesize heterostructures of graphdiyne-encapsulated molybdenum disulfide nanosheet on conductive 3D carbon fiber network (GDY-MoS2 NS/CF). The heterostructure showed efficient hydrogen evolution reaction (HER) in both acidic and alkaline electrolytes. All of the results for experiments and theoretical calculations evidenced that GDY can be chemisorbed on the surface of MoS2, which lead to the 2H-to-1T phase transformation of MoS2, and the enhancement of electric conductivity, and thus giving a near-zero Gibbs free energy. The GDY-MoS2 NS/CF shows a better HER activity with a low overpotential of only 90 mV to deliver current density of 10 mA cm−2 in alkaline conditions, which is superior to that of 20% Pt/C (103 mV) and 45.7 times larger than pristine MoS2 in transient photocurrent. The catalytic mechanisms of such GDY-based heterostructures are clear for understanding the catalytic mechanism on the atomic level. The unique heterostructure of the GDY encapsulating MoS2 showed high HER activity and the electrocatalyst with extraordinary long-term stability at all pH values, which compares favourably to all reported MoS2-based electrocatalysts and most of other benchmarked electrocatalysts. This provide an efficient strategy for developing highly active and stable electrocatalyst.