Early detection and effective treatment of myocardial infarction can prevent the deterioration of ischemic heart disease and greatly reduce the possibility of sudden death. On the basis of standard 12-lead electrocardiogram (ECG) records, this paper proposes a bidirectional, long short-term memory (Bi-LSTM) network with a heartbeat-attention mechanism to effectively and automatically detect myocardial infarction (MI). First, we divide the standard 12-lead ECG records into sliding windows with the same number of heartbeats. Subsequently, we do not use any labels of heartbeats to train the Bi-LSTM network and the heartbeat-attention mechanism is applied to automatically weight the difference between unlabeled heartbeats. Finally, our method is validated by patients’ complete ECG records and real labels in the Physikalisch-Technische Bundesanstalt (PTB) diagnostic ECG database. When compared with the same network without the heartbeat-attention mechanism or other existing methods, our method achieves comparable or better performance. The accuracy, sensitivity, and specificity reach 94.77%, 95.58%, and 90.48%, respectively.