  [Abridged] We present a comprehensive investigation of the cosmological
evolution of the luminosity function (LF) of galaxies and active galactic
nuclei (AGN) in the infrared (IR). Based on the observed dichotomy in the ages
of stellar populations of early-type galaxies on one side and late-type
galaxies on the other, the model interprets the epoch-dependent LFs at z \geq
1.5 using a physical model for the evolution of proto-spheroidal galaxies and
of the associated AGNs, while IR galaxies at z<1.5 are interpreted as being
mostly late-type 'cold' (normal) and 'warm' (starburst) galaxies. As for
proto-spheroids, in addition to the epoch-dependent LFs of stellar and AGN
components separately, we have worked out the evolving LFs of these objects as
a whole (stellar plus AGN component). The model provides a physical explanation
for the observed positive evolution of both galaxies and AGNs up to z \simeq
2.5 and for the negative evolution at higher redshifts, for the sharp
transition from Euclidean to extremely steep counts at (sub-)mm wavelengths, as
well as the (sub-)mm counts of strongly lensed galaxies, that are hard to
account for by alternative, physical or phenomenological, approaches. The
evolution of late-type galaxies and of z<1.5 AGNs is described using a
parametric phenomenological approach. The modeled AGN contributions to the
counts and to the cosmic infrared background (CIB) are always subdominant with
maximal at mid-IR wavelengths. The model provides a good fit to the
multi-wavelength (from the mid-IR to millimeter waves) data on LFs at different
redshifts and on number counts (both global and per redshift slices). A
prediction of the present model is a systematic variation with wavelength of
the populations dominating the counts and the contributions to the CIB
intensity. The implied specific trend for cross-wavelength CIB power spectra is
found to be in good agreement with the data.
