Gravitational waves enable tests of general relativity in the highly dynamical and strong-field regime. Using events detected by LIGO-Virgo up to 1 October 2019, we evaluate the consistency of the data with predictions from the theory. We first establish that residuals from the best-fit waveform are consistent with detector noise, and that the low- and high-frequency parts of the signals are in agreement. We then consider parametrized modifications to the waveform by varying post-Newtonian and phenomenological coefficients, improving past constraints by factors of ~2; we also find consistency with Kerr black holes when we specifically target signatures of the spin-induced quadrupole moment. Looking for gravitational-wave dispersion, we tighten constraints on Lorentz-violating coefficients by a factor of ~2.6 and bound the mass of the graviton to m_g ≤ 1.76 × 10^−23 eV/c2 with 90% credibility. We also analyze the properties of the merger remnants by measuring ringdown frequencies and damping times, constraining fractional deviations away from the Kerr frequency to δf_220 = 0.03 (+0.38, −0.35) for the fundamental quadrupolar mode, and δf_221 = 0.04 (+0.27,−0.32) for the first overtone; additionally, we find no evidence for postmerger echoes. Finally, we determine that our data are consistent with tensorial polarizations through a template-independent method. When possible, we assess the validity of general relativity based on collections of events analyzed jointly. We find no evidence for new physics beyond general relativity, for black hole mimickers, or for any unaccounted systematics.