In this paper, a novel algorithm was proposed to subtract power line interference (PLI) from contaminated ECG signal. Firstly, some PLI values were calculated from ECG signal in linear segment. Secondly, using nonlinear regression and least squares estimation, sinusoidal parameters such as frequency and phase were estimated from the calculated PLI values. Thirdly, the PLI values in the nonlinear segment closest to the linear segment were determined by the sinusoid function with the estimated parameters. Lastly, PLI was subtracted from the contaminated ECG signal in nonlinear segment. The method's performance was tested in ECG databases in www.physionet.org. The experiment results show that the proposed method can more effectively remove PLI from ECG signal than other algorithms even when PLI frequency fluctuates, and do not distort the shape of ECG signal.