We consider nonlinear algebraic systems arising from numerical discretizations of nonlinear partial differential equations of diffusion type. In order to solve them, some iterative nonlinear solver, and, on each step of this solver, some iterative linear solver are used. We propose an adaptive choice of the number of steps of both the linear and nonlinear solvers. Both stopping criteria are based on an a posteriori error estimate which distinguishes the different error components, namely the algebraic error, the linearization error, and the discretization error; we stop whenever the corresponding error does not affect the overall error significantly. Our estimates also give a guaranteed upper bound on the overall error at each step of the nonlinear and linear solvers. We prove the (local) efficiency and robustness of our estimates with respect to the size of the nonlinearity. This is achieved thanks to the choice of the error measure, the dual norm of the residual augmented by a jump seminorm. Our developments are carried at an abstract level, yielding a general framework. We apply this framework to the fixed point and Newton linearizations and to most common discretization methods: the finite element, the nonconforming finite element, the discontinuous Galerkin, and finite volume and mixed finite element ones. All iterative linear solvers are covered. Numerical experiments illustrate the tight overall error control and important computational savings achieved by our approach.