Modification of electronic and chemical properties of a material by the introduction of another element into its lattice is one of the most common methods for designing new catalysts for different applications. In this work the effect of modifying molybdenum carbide with transition metals (Fe, Co, Ni, Cu), TM-Mo2C composites, upon the catalytic activity toward hydrogen evolution reaction (HER) in mild acidic and alkaline media has been studied. Catalysts were prepared by carbothermal reduction of molybdenum and TM oxides precursors and were characterized by different physicochemical techniques. Results evidenced a strong pH effect on the catalytic performance of TM-Mo2C, while, at pH = 5, inclusion of TM into the Mo2C lattice has a deleterious effect on the HER activity and, at pH = 9, a promoting effect was observed, highlighting the importance of considering specific operation conditions during the catalyst design process. Analysis of in situ near-edge X-ray adsorption data reveals a decrease on the oxidation state and average bond ionicity of dopant metal upon a pH increase, shedding light of the different effects of TMs on the resulting HER activity in acidic and alkaline media. Finally, stability tests demonstrated no deterioration on catalysts' performance after 8 h of continuous cycling within the HER working range, confirming the suitability of Mo2C materials as promising HER catalysts.