This study presents a photooxidation strategy to develop near-infrared (NIR) afterglow carbon nanodots (CDs) with an ultra-long lifetime of up to 5.9 hours, comparable to rare-earth or organic long-persistent luminescent materials. The size-dependent afterglow lifetime evolution from 3.4 to 5.9 hours is observed in aqueous solutions. Structural and ultrafast dynamics analysis, along with density functional theory (DFT) simulations, reveal that the persistent luminescence is activated by a photooxidation-induced dioxetane intermediate, which slowly releases and converts energy into luminous emission via steric hindrance effects. The NIR afterglow CDs achieve a tissue penetration depth of 20 mm and exhibit good biological safety and cancer-specific targeting ability. In vivo experiments demonstrate the successful use of NIR afterglow CDs for imaging-guided surgery in mice, accurately removing tumor tissues. These findings highlight the potential of long-lasting luminescent materials for precision tumor resection.This study presents a photooxidation strategy to develop near-infrared (NIR) afterglow carbon nanodots (CDs) with an ultra-long lifetime of up to 5.9 hours, comparable to rare-earth or organic long-persistent luminescent materials. The size-dependent afterglow lifetime evolution from 3.4 to 5.9 hours is observed in aqueous solutions. Structural and ultrafast dynamics analysis, along with density functional theory (DFT) simulations, reveal that the persistent luminescence is activated by a photooxidation-induced dioxetane intermediate, which slowly releases and converts energy into luminous emission via steric hindrance effects. The NIR afterglow CDs achieve a tissue penetration depth of 20 mm and exhibit good biological safety and cancer-specific targeting ability. In vivo experiments demonstrate the successful use of NIR afterglow CDs for imaging-guided surgery in mice, accurately removing tumor tissues. These findings highlight the potential of long-lasting luminescent materials for precision tumor resection.