Several window functions are currently applied to improve the performance of the discrete Fourier transform (DFT) harmonic detection method. These window functions exhibit poor accuracy in measuring the harmonic contents of a signal with high-order and weak-amplitude components when the power frequency fluctuates within a small range. In this paper, a minimum side-lobe optimization window function that is aimed at overcoming the abovementioned issue is proposed. Moreover, an improved DFT harmonic detection algorithm based on the six-term minimum side-lobe optimization window and four-spectrum-line interpolation method is proposed. In this context, the minimum side-lobe optimization window is obtained by optimizing the conventional cosine window function according to the optimization rules, and the characteristics of the new proposed window are provided to analyze its performance. Then, the proposed optimization window function is employed to improve the DFT harmonic detection algorithm based on the six-term minimum side-lobe optimization window and four-spectrum-line interpolation method. The proposed technique is used to detect harmonics of an electricity gird in which the six-term minimum side-lobe optimization window is utilized to eliminate the influence of spectrum leakage caused by nonsynchronous sampling of signal processing. The four-spectrum-line interpolation method is employed to eliminate or mitigate the fence effect caused by the inherent measurement error of the DFT method. Simulation experiments in two complex conditions and an experiment test are carried out to validate the improved performance of the proposed window. Results reveal that the six-term minimum side-lode optimization window has the smallest peak side lobe when compared with existing windows, which can effectively reduce the interaction influence of spectrum leakage, improve the measurement accuracy of the DFT harmonic detection method, and meet the standard requirement of harmonic measurement in complex situations.