In this paper, the performance of the classical Sliding Mode Controller (CSMC) is improved by using the Particle Swarm Optimization (PSO) technique. The PSO technique is used to obtain the optimal values of the CSMC parameters such as the gain K and the slope of sliding surface λ, and as a result, the response of the system is improved by decreasing the settling time of the system and makes the steady state error equal to zero. A single inverted pendulum, which is considered an example of a nonlinear system, has been used for testing the proposed controller. The simulation results are implementing by using the Programming and Simulink of Matlab, and the result shows a good validity of the proposed controller.