  In the early Universe, most of the cold neutral gas that will later form into
individual stars and galaxies is practically invisible to us. These neutral gas
reservoirs can, however, be illuminated by bright cosmic lightsources such as
gamma-ray bursts (GRBs) and quasars. The aim of this thesis is to use these
luminous objects as tools to study the environments of intervening or host
galaxy absorption systems through cosmic time. Part I is dedicated to examining
the gas, dust and metals in the immediate region surrounding GRBs. Part II
presents a search for and the study of cold and molecular gas in high-z GRB
host galaxy absorption systems. Part III focuses on using quasars to examine
gas-rich intervening galaxies in the line of sight, with specific focus on
absorption systems rich in dust and metals. This thesis demonstrates the
importance of observing large samples of GRB afterglows to 1) allow for
statistical studies of the GRB phenomena itself and the associated host galaxy
environments and 2) to obtain spectra of peculiar or unusual GRB afterglows,
that is only observed rarely. In addition, it highlights that defining a
complete and unbiased sample of quasars is vital to fully exploit the potential
of quasars as probes of cosmic chemical evolution. In this version of the
thesis only the title, author list and abstract for each published paper,
presented as individual chapters, are provided. Principal supervisor: Prof.
P\'all Jakobsson.
