Mn-based layered oxides are very attractive as cathodes for potassium-ion batteries (PIBs) due to their low-cost and environmentally friendly precursors. Their transfer to practical application, however, is inhibited by some issues including consecutive phase transitions, sluggish K+ deintercalation/intercalation, and serious capacity loss. Herein, Mg-Ni co-substituted K1/2Mn5/6Mg1/12Ni1/12O2 is designed as a promising cathode material for PIBs, with suppressed phase transitions that occurred in K1/2MnO2 and improved K+ storage performance. Part of Mg2+ and Ni2+ occupies the K+ layer, playing the role of a "nailed pillar", which restrains metal oxide layer gliding during the K+ (de)intercalation. The "Mg-Ni pinning effect"not only suppresses the phase transitions but also reduces the cell volume variation, leading to the improved cycle performance. Moreover, K1/2Mn5/6Mg1/12Ni1/12O2 has low activation barrier energy for K+ diffusion and high electron conductivity as demonstrated by first-principles calculations, resulting in better rate capability. In addition, K1/2Mn5/6Mg1/12Ni1/12O2 also delivers a higher reversible capacity owing to the participation of the Ni element in electrochemical reactions and the pseudocapacitive contribution. This study provides a basic understanding of structural evolution in layered Mn-based oxides and broadens the strategic design of cathode materials for PIBs.