Transition metal sulfides (TMSs) and transition metal phosphides (TMPs) have emerged as highly active catalysts for electrochemical applications. However, the present preparation methods for TMSs and TMPs are always complex and tedious. Herein, we developed a facile and effective strategy for synthesis of nitrogen (N)‐doped carbon‐coated TMSs or TMPs, which was realized by ball milling protic salts (p‐phenylenediamine bisulfate or p‐phenylenediamine biphosphate) and metal salts, followed by pyrolysis. A serious of TMSs and TMPs with well crystalline structures were obtained and witnessed by XRD analysis. Further electrocatalysis performance study in oxygen evolution reaction demonstrates that Ni‐modified MoS2/NC catalyst exhibited excellent activity, showing an overpotential of 261 mV at the current density of 10 mA cm−2 with a small Tafel slop of 53 mV dec−1. The satisfactory performance of Ni−MoS2/NC might be derived from the synergistic effect between Ni and MoS2 that led to enhanced charge transport capability and more efficient kinetics. This work not only provides a simple and general pathway to TMSs and TMPs‐based materials, but also enables excellent OER performance to be achieved.