A variational formalism that includes, in a consistent way, the tokamak plasma fluid response to an electromagnetic field as well as the particle-field resonant interaction effects is presented. The integrability of the unperturbed motion of the particles is used to establish a general functional similar to the classical Lagrangian for the electromagnetic field, which is extremum with respect to the field potentials. This functional is the sum of fluid terms that are closely related to the classical MHD energy and of resonant terms describing the kinetic effects. The formalism is used to study a critical issue in tokamak confinement, namely the sawteeth stabilization by energetic particles.