To enhance traffic safety on mountainous roads, this study proposes an innovative CNN-LSTM-Attention model designed for the identification of near-crash events, utilizing naturalistic driving data from the challenging terrains in Yunnan, China. A combination of a threshold method complemented by manual verification is used to label and annotate near-crash events within the dataset. The importance of vehicle motion features is evaluated using the random forest algorithm, revealing that specific variables, including x-axis acceleration, y-axis acceleration, y-axis angular velocity, heading angle, and vehicle speed, are particularly crucial for identifying near-crash events. Addressing the limitations of existing models in accurately detecting near-crash scenarios, this study combines the strengths of convolutional neural networks (CNN), long short-term memory (LSTM) networks, and an attention mechanism to enhance model sensitivity to crucial temporal and spatial features in naturalistic driving data. Specifically, the CNN-LSTM-Attention model leverages CNN to extract local features from the driving data, employs LSTM to track temporal dependencies among feature variables, and uses the attention mechanism to dynamically fine-tune the network weights of feature parameters. The efficacy of the proposed model is extensively evaluated against six comparative models: CNN, LSTM, Attention, CNN-LSTM, CNN-Attention, and LSTM-Attention. In comparison to the benchmark models, the CNN-LSTM-Attention model achieves superior overall accuracy at 98.8%. Moreover, it reaches a precision rate of 90.1% in detecting near-crash events, marking an improvement of 31.6%, 14.8%, 63.5%, 8%, 23.5%, and 22.6% compared to the other six comparative models, respectively.