Aiming at the deficiencies of insufficient cross-domain generalization and poor rhythm sensitivity in atrial fibrillation (AF) detection from multi-lead electrocardiogram (ECG) signals, this paper proposes a novel AF detection algorithm based on multi-scale patch attention fusion. The method segmented ECG signals into overlapping temporal fragments of different scales to capture local waveform details and long-range rhythm patterns respectively; it fused cross-scale feature information through a multi-scale attention mechanism to strengthen the model’s ability to perceive local and global rhythm features, and introduced the self-attention mechanism of Transformer to capture long-range rhythm correlations among fragments, thus realizing in-depth mining of ECG features. The algorithm was validated on the public CinC2021 dataset and the self-constructed clinical Clin-ECG dataset. Experimental results showed that the algorithm achieved an accuracy of 94.6% and 92.7% on the two datasets, with F1 scores reaching 0.945 and 0.923, respectively. Compared with baseline models such as ECG-ResNet and CNN-BiLSTM, the proposed algorithm exhibited higher accuracy and better cross-dataset generalization ability, providing an effective method for the automatic detection of AF from multi-lead ECG signals.