The vehicle lateral stability control algorithm is an essential component of the electronic stability program (ESP), and its control effect directly affects the vehicle’s driving safety. However, there are still numerous shortcomings and challenges that need to be addressed, including enhancing the efficiency of processing intricate pavement condition data, improving the accuracy of parameter adjustment, and identifying subtle and elusive patterns amidst noisy and ambiguous data. The introduction of machine learning algorithms can address the aforementioned issues, making it imperative to apply machine learning to the research of lateral stability control algorithms. This paper presented a vehicle lateral electronic stability control algorithm based on the back propagation (BP) neural network and PID control algorithm. Firstly, the dynamics of the whole vehicle have been analytically modeled. Then, a 2 DOF prediction model and a 14 DOF simulation model were built in MATLAB Simulink to simulate the data of the electronic control units (ECU) in ESP and estimate the dynamic performance of the real vehicle. In addition, the self-correction of the PID algorithm was verified by a Simulink/CarSim combined simulation. The improvement of the BP neural network to the traditional PID algorithm was also analyzed in Simulink. These simulation results show the self-correction of the PID algorithm on the lateral stability control of the vehicle under different road conditions and at different vehicle speeds. The BP neural network smoothed the vehicle trajectory controlled by traditional PID and improved the self-correction ability of the control system by iterative training. Furthermore, it shows that the algorithm can automatically tune the control parameters and optimize the control process of the lateral electronic stability control algorithm, thus improving vehicle stability and adapting it to many different vehicle models and road conditions. Therefore, the algorithm has a high practical value and provides a feasible idea for developing a more intelligent and general vehicle lateral electronic stability system.