Abnormal driving behavior is one of the main causes of roadway collisions. In most studies of abnormal driving behavior, the abnormal driving status is detected and analyzed using classification algorithms directly or using unsupervised learning algorithms to classify reconstruction or prediction residuals. However, abnormal driving behavior data are difficult to acquire and label. Also, a class imbalance issue is inherent in the algorithm training process due to the relatively sparse data for abnormal driving behavior. Moreover, current studies that include residual analysis tend to focus on individual points and thus fail to capture the continuity characteristic of abnormal driving behavior.To address these problems, a long short-term memory-residual (LSTM-R) algorithm is proposed to detect abnormal driving behavior in real time. The proposed algorithm (referred to simply as LSTM-R) has two steps. First, an LSTM network is used to fit the current vehicle kinematic data based on historical data to obtain the root mean square residual at each moment. Second, a time window-based residual algorithm is designed and employed to detect abnormal driving behavior according to the magnitude and continuity of the residuals. To verify the effectiveness of LSTM-R, an experimental test was conducted in Nanjing, China. The vehicle kinematic data were collected non-intrusively using a smartphone.In addition, AdaCost, SMOTEBoost, EasyEnsemble, LightGBM-residual, and linear regression-residual algorithms were employed for comparison with the proposed algorithm to assess its effectiveness. The effects of (1) the degree-of-fit of the LSTM network, (2) the LSTM-R parameters, and (3) the abnormal driving behavior percentage on the detection results were analyzed in detail. First, both the underfitting and overfitting of the LSTM network compromise the detection performance. Second, within a certain range of values, the LSTM-R parameters have little effect on the detection results. Third, the detection results are affected only slightly by the abnormal proportion. The results show that LSTM-R, with a maximum F1-score of 0.866, significantly outperforms the other five algorithms. Furthermore, even if only 10% abnormal driving behavior is in the training set, LSTM-R’s F1-score can still be close to 0.86, indicating a significant relaxation of the requirements for labeled data. Also, the required data are easy to collect, which indicates LSTM-R’s extensive application possibilities. This paper thus provides an effective method for the real-time detection of abnormal driving behavior and also supports driving risk assessment and driving behavior improvement with the overall goal to enhance roadway safety.