We derive the first law of black hole mechanics for physical theories based on a local, covariant and gauge-invariant Lagrangian where the dynamical fields transform non-trivially under the action of some internal gauge transformations. The theories of interest include General Relativity formulated in terms of tetrads, Einstein-Yang-Mills theory and Einstein-Dirac theory. Since the dynamical fields of these theories have some internal gauge freedom, we argue that there is no natural group action of diffeomorphisms of spacetime on such dynamical fields. In general, such fields cannot even be represented as smooth, globally well-defined tensor fields on spacetime. Consequently the derivation of the first law by Iyer and Wald cannot be used directly. Nevertheless, we show how such theories can be formulated on a principal bundle and that there is a natural action of automorphisms of the bundle on the fields. These bundle automorphisms encode both spacetime diffeomorphisms and internal gauge transformations. Using this reformulation we define the Noether charge associated to an infinitesimal automorphism and the corresponding notion of stationarity and axisymmetry of the dynamical fields. We first show that we can define certain potentials and charges at the horizon of a black hole so that the potentials are constant on the bifurcate Killing horizon, giving a generalised zeroth law for bifurcate Killing horizons. We further identify the gravitational potential and perturbed charge as the temperature and perturbed entropy of the black hole which gives an explicit formula for the perturbed entropy analogous to the Wald entropy formula. We then obtain a general first law of black hole mechanics for such theories. The first law relates the perturbed Hamiltonians at spatial infinity and the horizon, and the horizon contributions take the form of a “potential times perturbed charge” term. We also comment on the ambiguities in defining a prescription for the total entropy for black holes.