One of the most promising ways to probe intergalactic magnetic fields (IGMFs) is through gamma rays produced in electromagnetic cascades initiated by high-energy gamma rays or cosmic rays in the intergalactic space. Because the charged component of the cascade is sensitive to magnetic fields, gamma-ray observations of distant objects such as blazars can be used to constrain IGMF properties. Ground-based and space-borne gamma-ray telescopes deliver spectral, temporal, and angular information of high-energy gamma-ray sources, which carries imprints of the intervening magnetic fields. This provides insights into the nature of the processes that led to the creation of the first magnetic fields and into the phenomena that impacted their evolution. Here we provide a detailed description of how gamma-ray observations can be used to probe cosmic magnetism. We review the current status of this topic and discuss the prospects for measuring IGMFs with the next generation of gamma-ray observatories.