The Cherenkov Telescopic Array (CTA), the next-generation ground-based gamma-ray observatory, will have unprecedented sensitivity, providing answers to open questions in gamma-ray cosmology and fundamental physics. Using simulations of active galactic nuclei observations foreseen in the CTA Key Science Program, we find that CTA will measure gamma-ray absorption on the extragalactic background light with a statistical error below 15% up to the redshift of 2 and detect or establish limits on gamma halos induced by the intergalactic magnetic field of at least 0.3 pG. Extragalactic observations using CTA also demonstrate the potential for testing physics beyond the Standard Model. The best state-of-the-art constraints on the Lorentz invariance violation from astronomical gamma-ray observations will be improved at least two- to threefold. CTA will also probe the parameter space where axion-like particles can represent a significant proportion – if not all – of dark matter. Joint multiwavelength and multimessenger observations, carried out together with other future observatories, will further foster the growth of gamma-ray cosmology.