A complete, rigorous relativistic field-theory formulation of the nucleon-nucleon (N N ) bremsstrahlung reaction is presented. The resulting amplitude is unitary as a matter of course and it is gauge invariant, i.e., it satisfies a generalized Ward-Takahashi identity. The novel feature of this approach is the consistent microscopic implementation of local gauge invariance across all interaction mechanisms of the hadronic systems, thus serving as a constraint for all subprocesses. The formalism is quite readily adapted to approximations and thus can be applied even in cases where the microscopic dynamical structure of the underlying interacting hadronic systems is either not known in detail or too complex to be treated in detail. We point out how the interaction currents resulting from the photon being attached to nucleon-nucleon-meson vertices can be treated by phenomenological four-point contact currents that preserve gauge invariance. In an advance application of the present formalism [K. Nakayama and H. Haberzettl, Phys. Rev. C 80, 051001 (2009)], such interaction currents were found to contribute significantly in explaining experimental data. In addition, we provide a scheme that permits -through an introduction of phenomenological five-point contact currents -the approximate treatment of current contributions resulting from pieces of the N N interaction that cannot be incorporated exactly. In each case, the approximation procedure ensures gauge invariance of the entire bremsstrahlung amplitude. We also discuss the necessary modifications when taking into account baryonic states other than the nucleon N ; in detail, we consider the ∆(1232) resonance by incorporating the couplings of the N N to the N ∆ and ∆∆ systems, and the γN → ∆ transitions. We apply the formalism to the 280-MeV bremsstrahlung data from TRIUMF [Phys. Rev. D 41, 2689(1990] incorporating γN ∆ transition currents and find good agreement with the data.