A novel automated system is presented for improved detection of transient ischaemic and heart rate-related ST-segment episodes in 'real-world' 24 h ambulatory ECG data. Using a combination of traditional time-domain and Karhunen-Loève transform-based approaches, the detector derives QRS complex and ST-segment morphology feature vectors and, by mimicking human examination of feature-vector time series and their trends, tracks the time-varying ST-segment reference level owing to clinically unimportant, non-ischaemic causes, such as slow drifts, axis shifts and conduction changes. The detector estimates the slowly varying ST-segment level trend, identifies step changes in the time series and subtracts the ST-segment reference level thus obtained from the ST-segment level to obtain the ST-segment deviation time series, which are suitable for detection of ST-segment episodes. The detector was developed using the Long-term ST database containing 24 h ambulatory ECG records with human-expert annotated transient ischaemic and heart rate-related ST-segment episodes. The average ST episode detection sensitivity/positive predictivity obtained when using the annotations of the annotation protocol B of the database were 78.9%/80.7%. Evaluation of the detector using the European Society of Cardiology ST-T database as a test database showed average ST episode detection sensitivity/positive predictivity of 81.3%/89.2%, which are better performances, comparable with those of the systems being developed using the European database.