This paper proposes a method for detecting and classifying ship abnormal behaviour in ship trajectories. The method involves generating parameter profiles for the ship's trajectory and applying a Sliding Window algorithm to detect the ship's abnormal behaviour. Then, several features are adopted to effectively describe the characteristics of each ship's abnormal behaviour, such as the standard deviation of speed, detour factor, maximum drift angle, accumulative change of Course Over Ground and maximum lateral distance to the ship route. A density-based clustering algorithm is applied to group similar abnormal behaviour patterns according to the feature similarity, and the Random Forest Classification method is used to train a classification model based on the features extracted from the clusters. The proposed method is then tested on historical ship trajectory data provided by the Automatic Identification System. The results suggest that the method effectively identifies and classifies different abnormal behaviours in the ship trajectories.