Eu2+-doped alkali or alkali earth iodide scintillators with energy resolutions ≤3% at 662 keV promise the excellent discrimination ability for radioactive isotopes required for homeland-security and nuclear-nonproliferation applications. To extend their applications to x-ray imaging, such as computed tomography scans, the intense afterglow which delays the response time of such materials is an obstacle that needs to be overcome. However, a clear understanding of the origin of the afterglow and feasible solutions is still lacking. In this work, we present a combined experimental and theoretical investigation of the physical insights of codoping-based defect engineering which can reduce the afterglow effectively in KCaI3:Eu2+ single-crystal scintillators. We illustrate that Sc3+ codoping greatly suppresses the afterglow, whereas Y3+, Gd3+, or La3+ codoping enhances the afterglow. Meanwhile, a light yield of 57 000 photons/MeV and an energy resolution of 3.4% at 662 keV can be maintained with the appropriate concentration of Sc3+ codoping, which makes the material promising for medical-imaging applications. Through our thermoluminescence techniques and density-functional-theory calculations, we are able to identify the defect structures and understand the mechanism by which codoping affects the scintillation performance of KCaI3:Eu2+ crystals. The proposed defect-engineering strategy is further validated by achieving afterglow suppression in Mg2+ codoped KCaI3:Eu2+ single crystals.