A new method for QRST cancellation is presented for the analysis of atrial fibrillation in the surface electrocardiogram (ECG). The method is based on a spatiotemporal signal model which accounts for dynamic changes in QRS morphology caused, e.g., by variations in the electrical axis of the heart. Using simulated atrial fibrillation signals added to normal ECGs, the results show that the spatiotemporal method performs considerably better than does straightforward average beat subtraction (ABS). In comparison to the ABS method, the average QRST-related error was reduced to 58 percent. The results obtained from ECGs with atrial fibrillation agreed very well with those from simulated fibrillation signals.