This paper proposes a repetitive learning-based phase locked loop (RLPLL) to improve power quality of the grid-connected dc microgrids under distorted grid voltage in a weak grid. The harmonic component present in grid current in a high impedance network amplifies the distortion in voltage, which often leads to instability. Since the behavior of the conventional synchronous reference frame PLL (SRF-PLL) varies, owing to the proportional-integral gains constrained to harmonic rejection bandwidth ultimately leading to a sluggish response. However, RLPLL accommodates this limitation with a comparable dynamic performance and enhanced harmonic attenuation properties. This has been achieved by using a Lyapunov-based approach for harmonic estimation, which facilitates the periodicity and boundedness of the harmonic component to obtain an adaptive learning-based update. To deal with the computational burden, this paper also provides a low-computing alternative model of the proposed strategy. The dynamic response of RLPLL along with a comparative analysis with SRF-PLL is governed by many events directly affecting the dc voltage, which is critical for the operation of dc microgrids. Its performance is validated under different scenarios in a 1-kVA field programmable gate array-based experimental setup.