  We demonstrate that, for the baseline design of the CORE satellite mission,
the polarized foregrounds can be controlled at the level required to allow the
detection of the primordial cosmic microwave background (CMB) $B$-mode
polarization with the desired accuracy at both reionization and recombination
scales, for tensor-to-scalar ratio values of ${r\gtrsim 5\times 10^{-3}}$. We
consider detailed sky simulations based on state-of-the-art CMB observations
that consist of CMB polarization with $\tau=0.055$ and tensor-to-scalar values
ranging from $r=10^{-2}$ to $10^{-3}$, Galactic synchrotron, and thermal dust
polarization with variable spectral indices over the sky, polarized anomalous
microwave emission, polarized infrared and radio sources, and gravitational
lensing effects. Using both parametric and blind approaches, we perform full
component separation and likelihood analysis of the simulations, allowing us to
quantify both uncertainties and biases on the reconstructed primordial
$B$-modes. Under the assumption of perfect control of lensing effects, CORE
would measure an unbiased estimate of $r=\left(5 \pm 0.4\right)\times 10^{-3}$
after foreground cleaning. In the presence of both gravitational lensing
effects and astrophysical foregrounds, the significance of the detection is
lowered, with CORE achieving a $4\sigma$-measurement of $r=5\times 10^{-3}$
after foreground cleaning and $60$% delensing. For lower tensor-to-scalar
ratios ($r=10^{-3}$) the overall uncertainty on $r$ is dominated by foreground
residuals, not by the 40% residual of lensing cosmic variance. Moreover, the
residual contribution of unprocessed polarized point-sources can be the
dominant foreground contamination to primordial B-modes at this $r$ level, even
on relatively large angular scales, $\ell \sim 50$. Finally, we report two
sources of potential bias for the detection of the primordial
$B$-modes.[abridged]
