A theory of two-pion photo- and electroproduction off the nucleon is derived considering all explicit three-body mechanisms of the interacting $pipi N$ system. The full three-body dynamics of the interacting $pipi N$ system is accounted for by the Faddeev-type ordering structure of the Alt-Grassberger-Sandhas equations. The formulation is valid for hadronic two-point and three-point functions dressed by arbitrary internal mechanisms provided all associated electromagnetic currents are constructed to satisfy their respective (generalized) Ward-Takahashi identities. It is shown that coupling the photon to the Faddeev structure of the underlying hadronic two-pion production mechanisms results in a natural expansion of the full two-pion photoproduction current $M_{pipi}^mu$ in terms of multiple dressed loops involving two-body subsystem scattering amplitudes of the $pipi N$ system that preserves gauge invariance as a matter of course order by order in the number of (dressed) loops. A closed-form expression is presented for the entire gauge-invariant current $M_{pipi}^mu$ with complete three-body dynamics. Individually gauge-invariant truncations of the full dynamics most relevant for practical applications at the no-loop, one-loop, and two-loop levels are discussed in detail. An approximation scheme to the full two-pion amplitude for calculational purposes is also presented. It approximates, systematically, the full amplitude to any desired order of expansion in the underlying hadronic two-body amplitude. Moreover, it allows for the approximate incorporation of all neglected higher-order mechanisms in terms of a phenomenological remainder current. The effect and phenomenological usefulness of this remainder current is assessed in a tree-level calculation of the $gamma N to K K Xi$ reaction.