Developing high-performance batteries relies on material breakthroughs. During the past few years, various in situ characterization tools have been developed and have become indispensible in studying and the eventual optimization of battery materials. However, soft X-ray spectroscopy, one of the most sensitive probes of electronic states, has been mainly limited to ex situ experiments for battery research. Here we achieve in situ and operando soft X-ray absorption spectroscopy of lithium-ion battery cathodes. Taking advantage of the elemental, chemical and surface sensitivities of soft X-rays, we discover distinct lithium-ion and electron dynamics in Li(Co(¹/₃)Ni(¹/₃)Mn(¹/₃))O₂ and LiFePO₄ cathodes in polymer electrolytes. The contrast between the two systems and the relaxation effect in LiFePO₄ is attributed to a phase transformation mechanism, and the mesoscale morphology and charge conductivity of the electrodes. These discoveries demonstrate feasibility and power of in situ soft X-ray spectroscopy for studying integrated and dynamic effects in batteries.