We report results of a search for an isotropic gravitational-wave background (GWB) using data from Advanced LIGO’s and Advanced Virgo’s third observing run (O3) combined with upper limits from the earlier O1 and O2 runs. Unlike in previous observing runs in the advanced detector era, we include Virgo in the search for the GWB. The results of the search are consistent with uncorrelated noise, and therefore we place upper limits on the strength of the GWB. We find that the dimensionless energy density ΩGW≤5.8×10−9 at the 95% credible level for a flat (frequency-independent) GWB, using a prior which is uniform in the log of the strength of the GWB, with 99% of the sensitivity coming from the band 20–76.6 Hz; ΩGW(f)≤3.4×10−9 at 25 Hz for a power-law GWB with a spectral index of 2/3 (consistent with expectations for compact binary coalescences), in the band 20–90.6 Hz; and ΩGW(f)≤3.9×10−10 at 25 Hz for a spectral index of 3, in the band 20–291.6 Hz. These upper limits improve over our previous results by a factor of 6.0 for a flat GWB, 8.8 for a spectral index of 2/3, and 13.1 for a spectral index of 3. We also search for a GWB arising from scalar and vector modes, which are predicted by alternative theories of gravity; we do not find evidence of these, and place upper limits on the strength of GWBs with these polarizations. We demonstrate that there is no evidence of correlated noise of magnetic origin by performing a Bayesian analysis that allows for the presence of both a GWB and an effective magnetic background arising from geophysical Schumann resonances. We compare our upper limits to a fiducial model for the GWB from the merger of compact binaries, updating the model to use the most recent data-driven population inference from the systems detected during O3a. Finally, we combine our results with observations of individual mergers and show that, at design sensitivity, this joint approach may yield stronger constraints on the merger rate of binary black holes at z≳2 than can be achieved with individually resolved mergers alone.