An on-line offset current compensation method is proposed to improve ultra-high resistance (UHR) measurement more accurately and reliably. Iterative compensation algorithm is firstly adopted to generate compensation current by adjusting the compensation DAC to decrease the offset current to approximate zero, and then on-line offset current measurement algorithm is employed to ensure the time-varying offset current is always in an appropriate range. This algorithm can maintain a continuous unsaturated measurement process. Experiment results show that the uncertainty (k=2) is 1.4% for 1014Ω and 5.5% for 1015Ω under ±1000V based on the offset current compensation method proposed, which has been successfully implemented in a commercial UHR meter.