We define a new functional which is gauge invariant on the space of all smooth connections of a vector bundle over a compact Riemannian manifold. This functional is a generalization of the classical Yang-Mills functional. We derive its first variation formula and prove the existence of critical points. We also obtain the second variation formula.