The electrocardiogram (ECG) based biometric sys- tem has recently gained popularity. Easy signal acquisition and robustness against falsification are the major advantages of the ECG based biometric system. This biometric system can help automate the subject identification and authentication aspect of personalised healthcare services. In this paper, we have designed a novel attention based hierarchical long short-term memory (LSTM) model to learn the biometric representation correspond- ing to a person. The hierarchical LSTM model proposed in this paper can learn the temporal variation of the ECG signal in different abstractions. This addresses the long term dependency issue of the LSTM network in our application. The attention mechanism of the model learns to capture the ECG complexes that have more biometric information corresponding to each person. These ECG complexes are given more weight to learn better biometric representation. The proposed system is less complex and more efficient as it does not require the detection of any fiducial points. We have evaluated the proposed model for both the person verification and identification problems using two on-the-person ECG databases and two off-the-person ECG databases. The proposed framework is found to perform better than the existing fiducial and non-fiducial point based methods.