Commutation failure is a common fault for line-commutated converters in the inverter. To reduce the possibility of commutation failure, many prediction algorithms based on alternating current (AC) voltage detection have already been implemented in high voltage direct current (HVDC) control and protection systems. Nevertheless, there are currently no effective methods to prevent commutation failure due to transformer excitation surge current. In this paper, an improved commutation failure prediction algorithm based on the harmonic characteristics of the converter bus voltage during transformer charging is proposed. Meanwhile, a sliding-window iterative algorithm of discrete Fourier transformation (DFT) is developed for detecting the voltage harmonic in real time. This method is proved to be an effective solution, which prevents commutation failure in cases of excitation surge current, through experimental analysis. This method is already implemented into TianShan-ZhongZhou (TianZhong) ± 800 kV ultra high voltage direct current (UHVDC) system.