Analysis of heartbeat signals is critical to provide information for the diagnosis of cardiac diseases, e.g., beat detection, segmentation and classification based on electrocardiogram (ECG) signals. This paper proposes an automatic heartbeat classification system based on higher order hidden Markov models (HOHMMs). The proposed system consists of four stages: ECG signal preprocessing stage, HOHMM learning stage, decoding stage, and classification stage. The HOHMM extends the basic hidden Markov model (HMM) by allowing the hidden state to depend on its more distant past, which is used to identify heartbeat patterns utilizing the collected ECG data. The learned HOHMMs are then used to decode and classify new heartbeats with unknown types. A case study is conducted to evaluate the classification performance of the proposed system using MIT-BIH Arrhythmia database. Experimental results show that the developed classification system performs reasonably well, especially for arrhythmia detection.