Observations of distant quasars indicate that supermassive black holes of billions of solar masses already existed less than a billion years after the Big Bang. Models in which the `seeds' of such black holes form by the collapse of primordial metal-free stars cannot explain the rapid appearance of these supermassive black holes because gas accretion is not sufficiently efficient. Alternatively, these black holes may form by direct collapse of gas within isolated protogalaxies, but current models require idealized conditions, such as metal-free gas, to prevent cooling and star formation from consuming the gas reservoir. Here we report simulations showing that mergers between massive protogalaxies naturally produce the conditions for direct collapse into a supermassive black hole with no need to suppress cooling and star formation. Merger-driven gas inflows give rise to an unstable, massive nuclear gas disk of a few billion solar masses, which funnels more than 108 solar masses of gas to a sub-parsec-scale gas cloud in only 100,000 years. The cloud undergoes gravitational collapse, which eventually leads to the formation of a massive black hole. The black hole can subsequently grow to a billion solar masses on timescales of about 108 years by accreting gas from the surrounding disk.