The merger rate of black hole binaries inferred from the detections in the first Advanced LIGO science run, implies that a stochastic background produced by a cosmological population of mergers will likely mask the primordial gravitational-wave background. Here we demonstrate that the next generation of ground-based detectors, such as the Einstein Telescope and Cosmic Explorer, will be able to observe binary black hole mergers throughout the universe with sufficient efficiency that the confusion background can potentially be subtracted to observe the primordial background at the level of $Omega_{mathrm{GW}} simeq 10^{-13}$ after five years of observation.