The nonlinear refraction of silver nanoparticles (AgNPs) in n-hexane was studied by using the closed-aperture Z-scan technique with a 532 nm nanosecond laser. It was found that, the nonlinear refraction of AgNPs shows the coexistence and transformation from self-focusing to self-defocusing. Specifically, self-focusing occurs at low excitation intensity, self-defocusing occurs at high excitation intensity, and coexistence of self-focusing and self-defocusing occurs at relatively moderate excitation intensity. The experimental results were analysed and discussed in terms of third-order and fifth-order nonlinear refractive effect. Specifically, the self-focusing is caused by the positive third-order nonlinear refraction, the self-defocusing is induced by the negative fifth-order nonlinear refraction, and the transformation from the self-focusing to self-defocusing at medium excitation intensity is caused by the competition of third-order and fifth-order nonlinear refraction. Finally, the third-order refractive index and fifth-order refractive index were obtained.