  We study the gauge invariance of the massive modes in the compactification of
gauge theories from D=5 to D=4. We deal with Abelian gauge theories of rank one
and two, and with non-Abelian ones of rank one. We show that St\"uckelberg
fields naturally appear in the compactification mechanism, contrarily to what
usually occurs in literature where they are introduced by hand, as a trick, to
render gauge invariance for massive theories. We also show that in the
non-Abelian case they appear in a very different way when compared with their
usual implementation in the non-Abelian Proca model.
