The fast Fourier transform (FFT) has been widely used for the signal processing because of its computational efficiency. Because of the spectral leakage and picket-fence effects associated with the system fundamental frequency variation and improperly selected sampling time window, a direct application of the FFT algorithm with a constant sampling rate may lead to inaccurate results for continuously measuring power system harmonics and interharmonics. An improved FFT-based algorithm to measure harmonics and interharmonics accurately is proposed. In the proposed algorithm, a frequency-domain interpolation approach is adopted to determine the system fundamental frequency, and the interpolatory polynomial method is applied to reconstruct the sampled time-domain signal; it is followed by using the FFT to calculate the actual harmonic components. Then, the frequency-domain interpolation is again applied to find the interharmonic components. The performance of the proposed algorithm is validated by testing the actual measured waveforms. Results are compared with those obtained by directly applying a typical FFT algorithm and by the IEC grouping method. It shows that the solutions determined by the proposed algorithm are more accurate, and a reasonable computational efficiency is maintained.