The magnetic levitation system is a typical open-loop unstable system. To weaken the chattering phenomenon of sliding mode control (SMC), a hybrid control strategy of particle swarm sliding mode-fuzzy PID control was designed. This strategy uses particle swarm optimization (PSO) to optimize the SMC using the method of exponential approach law, so as to obtain the best sliding mode surface parameters and exponential approach rate coefficients, thus shortening the time required to approach the stable region when the nonlinear system is far from the stable point; a state supervision controller was designed by analyzing the stable conditions of sliding mode. When the system approaches the stable region, it smoothly transitions to fuzzy PID control, thereby weakening the chattering phenomenon of SMC. To verify the dynamic performance of the designed algorithm, a magnetic levitation ball system was selected as the controlled object. Through simulation and experiment, it was verified that the controller had strong robustness and strong anti-interference performance. It effectively weakened the chattering and had good adaptability to external disturbance and state variable crossing.