Cardiac arrhythmias are the leading cause of death and pose a huge health and economic burden globally. Electrocardiography (ECG) is an effective technique for the diagnosis of cardiovascular diseases because of its noninvasive and cost-effective advantages. However, traditional ECG analysis relies heavily on the clinical experience of physicians, which can be challenging and time-consuming to produce valid diagnostic results. This work proposes a new hybrid deep learning model that combines convolutional neural network (CNN) and bidirectional gated recurrent unit (BiGRU) with multi-head attention (CBGM model). Specifically, the model consists of seven convolutional layers with varying filter sizes (4, 16, 32, and 64) and three pooling layers, respectively, while the BiGRU module includes two layers with 64 units each followed by multi-head attention (8-heads). The combination of CNN and BiGRU effectively captures spatio-temporal features of ECG signals, with multi-head attention comprehensively extracted global correlations among multiple segments of ECG signals. The validation in the MIT-BIH arrhythmia database achieved an accuracy of 99.41%, a precision of 99.15%, a specificity of 99.68%, and an F1-Score of 99.21%, indicating its robust performance across different evaluation metrics. Additionally, the model’s performance was evaluated on the PTB Diagnostic ECG Database, where it achieved an accuracy of 98.82%, demonstrating its generalization capability. Comparative analysis against previous methods revealed that our proposed CBGM model exhibits more higher performance in automatic classification of arrhythmia and can be helpful for assisting clinicians by enabling real-time detection of cardiac arrhythmias during routine ECG screenings.