In this work we propose a nonlinear control strategy of single-phase unified power flow controller (UPFC), using in order to enhance energy quality parameters of a perturbed single-phase power grid supplying nonlinear loads. The control objectives are: i) The current harmonics and the reactive power compensation, that ensure a satisfactory power factor correction (PFC) at the point of common coupling (PCC); ii) compensation of the voltage perturbations (harmonics and sags of voltage) in order to ensure the desired level, of load voltage, without distortion; iii) DC bus voltage regulation. The considered control problem entails several difficulties including the high system dimension and the strong system nonlinearity. The problem is dealt with by designing a nonlinear controller with structure including three control loops. The inner-loop regulator is designed using the Lyapunov technique to compensate the current harmonics and reactive power. The intermediary-loop regulator is designed using the Backstepping technique to compensate the voltage perturbations. The outer-loop regulator is designed using a linear PI to regulate the DC bus voltage. The control stability is proved theoretically and through simulations, these latter show the effectiveness and strong robustness of the proposed control, and prove that the above-mentioned objectives are achieved.