"Objective: The electrocardiogram (ECG) is currently the most widely used recording to diagnose cardiac disorders, including the most common supraventricular arrhythmia, such as atrial fibrillation (AF). However, different types of electrical disturbances, in which power-line interference (PLI) is a major problem, can mask and distort the original ECG morphology. This is a significant issue in the context of AF, because accurate characterization of fibrillatory waves (f-waves) is unavoidably required to improve current knowledge about its mechanisms. This work introduces a new algorithm able to reduce high levels of PLI and preserve, simultaneously, the original ECG morphology. Approach: The method is based on stationary wavelet transform shrinking and makes use of a new thresholding function designed to work successfully in a wide variety of scenarios. In fact, it has been validated in a general context with 48 ECG recordings obtained from pathological and non-pathological conditions, as well as in the particular context of AF, where 380 synthesized and 20 long-term real ECG recordings were analyzed. Main results: In both situations, the algorithm has reported a notably better performance than common methods designed for the same purpose. Moreover, its effectiveness has proven to be optimal for dealing with ECG recordings affected by AF, since f-waves remained almost intact after removing very high levels of noise. Significance: The proposed algorithm may facilitate a reliable characterization of the f-waves, preventing them from not being masked by the PLI nor distorted by an unsuitable filtering applied to ECG recordings with AF."