An ingeniously designed porous structure can synergistically optimize the desired properties and maximize the advantages of a material as an electrode for a high-performance energy storage system. The active material with a porous nanostructure could reduce the ion diffusion path and buffer the strain caused by the volume changes during cycling. Furthermore, combining the active material with a three-dimensional (3D) graphene aerogel (GA) matrix is an ideal way to maintain the structural integrity, improve the conductivity, and overcome the aggregation problem of the nanomaterials. Herein, we adopted a facile template-based strategy to derive a composite of 3D hierarchically porous cobalt phosphide nanocubes with a graphene aerogel (CoP@GA). The as-prepared CoP@GA features porous cobalt phosphide nanocubes that are firmly encapsulated and uniformly distributed in the well-defined graphene aerogel skeleton. Benefiting from the hierarchical porosity, structural integrity, and conductive network, the CoP@GA electrode manifests an ultrahigh initial Coulombic efficiency (88.6%), outstanding lithium storage performance in terms of excellent cycling performance (805.3 mAh·g-1 after 200 cycles at 200 mA·g-1), superior high-energy performance (351.8 mAh·g-1 after 4000 cycles at 10 A·g-1), and exceptional rate capability. Moreover, this synthesis protocol could be an instructive precedent for fabricating transition-metal-phosphide-based 3D porous composites with excellent electrochemical performances.