  The origin of the extragalactic $\gamma$-ray background (EGB) has been
debated for some time. { The EGB comprises the $\gamma$-ray emission from
resolved and unresolved extragalactic sources, such as blazars, star-forming
galaxies and radio galaxies, as well as radiation from truly diffuse
processes.} This letter focuses on the blazar source class, the most numerous
detected population, and presents an updated luminosity function and spectral
energy distribution model consistent with the blazar observations performed by
the {\it Fermi} Large Area Telescope (LAT). We show that blazars account for
50$^{+12}_{-11}$\,\% of the EGB photons ($>$0.1\,GeV), and that {\it Fermi}-LAT
has already resolved $\sim$70\,\% of this contribution. Blazars, and in
particular low-luminosity hard-spectrum nearby sources like BL Lacs, are
responsible for most of the EGB emission above 100\,GeV. We find that the
extragalactic background light, which attenuates blazars' high-energy emission,
is responsible for the high-energy cut-off observed in the EGB spectrum.
Finally, we show that blazars, star-forming galaxies and radio galaxies can
naturally account for the amplitude and spectral shape of the background in the
0.1--820\,GeV range, leaving only modest room for other contributions. This
allows us to set competitive constraints on the dark-matter annihilation cross
section.
