Accurate state of charge (SOC) estimation is very crucial to guarantee the safety and reliability of lithium-ion batteries, especially for those used in electric vehicles. Since the SOC is unmeasurable and nonlinearly varies with factors (e.g., current rate, battery degeneration, ambient temperature and measurement noise), a reliable and robust algorithm for SOC estimation is expected. In this paper, an optimal adaptive gain nonlinear observer (OAGNO) for SOC estimation is proposed. The particle swarm optimization (PSO) algorithm is employed to optimize parameters of the adaptive gain nonlinear observer (AGNO). A combined error is presented as the fitness function to evaluate the search performance of the PSO algorithm. To perform the PSO-based parameter optimization of the AGNO, a combined dynamic loading profile consisting of the Federal Urban Driving Schedule, the New European Driving Cycle and the Dynamic Stress Test is developed. The proposed approach is verified by experiments performed on Panasonic NCR18650PF lithium-ion batteries and compared with different parametric AGNOs. Experimental results indicate that the proposed OAGNO is helpful to improve the accuracy of battery SOC estimation compared with the non-optimal AGNO methods. Additionally, the OAGNO approach is robust against initial SOC error, current noise and different driving cycles.