Using Co-based metal-organic frameworks as the precursor, we synthesized cobalt selenide (CoSe2) nanoparticles imbedded in carbon cages. By simply controlling the annealing conditions, phase transformation of CoSe2 from the orthorhombic phase to the cubic phase has been realized. Benefitting from the metallic character, the cubic phase CoSe2 shows greatly enhanced electrocatalytic activity for both the hydrogen evolution reaction (HER) and the oxygen evolution reaction (OER). The as-prepared cubic phase CoSe2 electrode possesses onset overpotentials of 43 and 200 mV, and Tafel slopes of 51 and 83 mV dec−1 for HER and OER, respectively, which are remarkably superior to that of the orthorhombic phase CoSe2 catalyst and comparable to those of commercial noble-metal catalysts. In addition, the cubic phase CoSe2 electrode also demonstrates excellent stability after long-term operations. Our work not only provides a high performance catalyst for water splitting, but also introduces a new route to the design of a highly efficient catalyst by phase transformation.