Repetitive control strategies have been commonly applied in pulse-width-modulated (PWM) voltage source inverters (VSIs) for many industrial applications. This paper presents a repetitive controller for voltage harmonic mitigation of VSI-based islanded microgrids. The phase delay in the overall control system, e.g., the delay caused by the digital duty cycle calculation, PWM generation, and repetitive controller, has to be compensated by elaborately designed phase lead filters in order to prevent control performance deterioration and system instability. Nevertheless, quantificational analysis and practical design of the time advance unit in such filters are hardly found in existing literature works. In view of this, this paper proposes an explicit analysis of the phase lead filters and a novel design method of the time advance unit in repetitive controllers to ensure system stability. Moreover, with the help of the proposed method, the overall system stability margin is predictable and improved controller performance is achieved as well. The proposed method is implemented experimentally to show the accurate stability margin calculation as well as the excellent steady state and dynamic performances of the repetitive control scheme.