  Mass and spin of massive black holes (BHs) at the centre of galaxies evolve
due to gas accretion and mergers with other BHs. Besides affecting e.g. the
evolution of relativistic jets, the BH spin determines the efficiency with
which the BH radiates energy. Using cosmological, hydrodynamical simulations,
we investigate the evolution of the BH spin across cosmic time and its role in
controlling the joint growth of supermassive BHs and their host galaxies. We
implement a sub-resolution prescription that models the BH spin, accounting for
both BH coalescence and misaligned accretion through a geometrically thin,
optically thick disc. We investigate how BH spin evolves in two idealised
setups, in zoomed-in simulations, and in a cosmological volume. The latter
simulation allows us to retrieve statistically robust results as for the
evolution and distribution of BH spins as a function of BH properties. We find
that BHs with $M_{\rm BH}\lesssim 2 \times 10^{7}\;{\rm M}_{\odot}$ grow
through gas accretion, occurring mostly in a coherent fashion that favours
spin-up. Above $M_{\rm BH}\gtrsim 2 \times 10^{7}~{\rm M}_{\odot}$ the gas
angular momentum directions of subsequent accretion episodes are often
uncorrelated with each other. The probability of counter-rotating accretion and
hence spin-down increases with BH mass. In the latter mass regime, BH
coalescence plays an important role. The spin magnitude displays a wide variety
of histories, depending on the dynamical state of the gas feeding the BH and
the relative contribution of mergers and gas accretion. As a result of their
combined effect, we observe a broad range of values of the spin magnitude at
the high-mass end. Our predictions for the distributions of BH spin and
spin-dependent radiative efficiency as a function of BH mass are in very good
agreement with observations.
