Dislocations are always observed during crystal growth, and it is usually desirable to reduce the dislocation density in high-quality crystals. Here, the annihilation process of the 30° Shockley partial dislocation pairs in CdTe is studied by first-principles calculations. We found that the dislocations can glide relatively easily due to the weak local bonding. Our systematic study of the slipping mechanism of the dislocations suggests that the energy barrier for the annihilation process is low. Band structure calculations reveal that the band bending caused by the charge transfer between the two dislocation cores depends on the core-core distance. A simple linear model is proposed to describe the mechanism of formation of the dislocation pair. More importantly, we demonstrate that hole injection can affect the core structure, increase the mobility, and eventually trigger a spontaneous mutual annihilation, which could be employed as a possible facile way to reduce the dislocation density.