Designing and synthesizing stable electrocatalysts with outstanding performance for water splitting is an arduous and urgent task. Herein, Ru-anchored CoP embedded in N-doped porous carbon nanocubes (Ru-CoP/NCs) is successfully prepared. The Ru-CoP/NC reveals superior hydrogen evolution reaction (HER) and oxygen evolution reaction (OER) properties and stability under alkaline conditions, and the corresponding overpotentials are 22 and 330 mV at 10 mA·cm-2, respectively. The unique N-doped porous carbon nanocube could boost the conductivity, and the electronic structure of CoP can be adjusted by the anchoring of Ru. Therefore, the strong interaction between Ru atoms and CoP improves the hydrogen adsorption on the catalyst, hence boosting the HER/OER performance of the Ru-CoP/NC catalyst. This work provides a facile method to exploit high-performance catalysts for water splitting.