  We present the Flagship galaxy mock, a simulated catalogue of billions of
galaxies designed to support the scientific exploitation of the Euclid mission.
Euclid is a medium-class mission of the European Space Agency optimised to
determine the properties of dark matter and dark energy on the largest scales
of the Universe. It probes structure formation over more than 10 billion years
primarily from the combination of weak gravitational lensing and galaxy
clustering data. The breath of Euclid's data will also foster a wide variety of
scientific analyses. The Flagship simulation was developed to provide a
realistic approximation to the galaxies that will be observed by Euclid and
used in its scientific analyses. We ran a state-of-the-art N-body simulation
with four trillion particles, producing a lightcone on the fly. From the dark
matter particles, we produced a catalogue of 16 billion haloes in one octant of
the sky in the lightcone up to redshift z=3. We then populated these haloes
with mock galaxies using a halo occupation distribution and abundance matching
approach, calibrating the free parameters of the galaxy mock against observed
correlations and other basic galaxy properties. Modelled galaxy properties
include luminosity and flux in several bands, redshifts, positions and
velocities, spectral energy distributions, shapes and sizes, stellar masses,
star formation rates, metallicities, emission line fluxes, and lensing
properties. We selected a final sample of 3.4 billion galaxies with a magnitude
cut of H_E<26, where we are complete. We have performed a comprehensive set of
validation tests to check the similarity to observational data and theoretical
models. In particular, our catalogue is able to closely reproduce the main
characteristics of the weak lensing and galaxy clustering samples to be used in
the mission's main cosmological analysis. (abridged)
