  The Cherenkov Telescope Array (CTA), the new-generation ground-based
observatory for $\gamma$-ray astronomy, provides unique capabilities to address
significant open questions in astrophysics, cosmology, and fundamental physics.
We study some of the salient areas of $\gamma$-ray cosmology that can be
explored as part of the Key Science Projects of CTA, through simulated
observations of active galactic nuclei (AGN) and of their relativistic jets.
Observations of AGN with CTA will enable a measurement of $\gamma$-ray
absorption on the extragalactic background light with a statistical uncertainty
below 15% up to a redshift $z=2$ and to constrain or detect $\gamma$-ray halos
up to intergalactic-magnetic-field strengths of at least 0.3pG. Extragalactic
observations with CTA also show promising potential to probe physics beyond the
Standard Model. The best limits on Lorentz invariance violation from
$\gamma$-ray astronomy will be improved by a factor of at least two to three.
CTA will also probe the parameter space in which axion-like particles could
constitute a significant fraction, if not all, of dark matter. We conclude on
the synergies between CTA and other upcoming facilities that will foster the
growth of $\gamma$-ray cosmology.
