The exploration of ideal electrode materials overcoming the critical problems of large electrode volume changes and sluggish redox kinetics induced by large ionic radius of Na+ /K+ ions is highly desirable for sodium/potassium-ion batteries (SIBs/PIBs) toward large-scale applications. The present work demonstrates that single-phase ternary cobalt phosphoselenide (CoPSe) in the form of nanoparticles embedded in a layered metal-organic framework (MOF)-derived N-doped carbon matrix (CoPSe/NC) represents an ultrastable and high-rate anode material for SIBs/PIBs. The CoPSe/NC is fabricated by using the MOF as both a template and precursor, coupled with in situ synchronous phosphorization/selenization reactions. The CoPSe anode holds a set of intrinsic merits such as lower mechanical stress, enhanced reaction kinetics, as well as higher theoretical capacity and lower discharge voltage relative to its counterpart of CoSe2 , and suppressed shuttle effect with higher intrinsic electrical conductivity relative to CoPS. The involved mechanisms are evidenced by substantial characterizations and density functional theory (DFT) calculations. Consequently, the CoPSe/NC anode shows an outstanding long-cycle stability and rate performance for SIBs and PIBs. Moreover, the CoPSe/NC-based Na-ion full cell can achieve a higher energy density of 274Wh kg-1 , surpassing that based on CoSe2 /NC and most state-of-the-art Na-ion full cells based on P-, Se-, or S-containing binary/ternary anodes to date.