According to the current understanding of cosmic structure formation, the precursors of the most massive structures in the Universe began to form shortly after the Big Bang, in regions corresponding to the largest fluctuations in the cosmic density field. Observing these structures during their period of active growth and assembly—the first few hundred million years of the Universe—is challenging because it requires surveys that are sensitive enough to detect the distant galaxies that act as signposts for these structures and wide enough to capture the rarest objects. As a result, very few such objects have been detected so far. Here we report observations of a far-infrared-luminous object at redshift 6.900 (less than 800 million years after the Big Bang) that was discovered in a wide-field survey. High-resolution imaging shows it to be a pair of extremely massive star-forming galaxies. The larger is forming stars at a rate of 2,900 solar masses per year, contains 270 billion solar masses of gas and 2.5 billion solar masses of dust, and is more massive than any other known object at a redshift of more than 6. Its rapid star formation is probably triggered by its companion galaxy at a projected separation of 8 kiloparsecs. This merging companion hosts 35 billion solar masses of stars and has a star-formation rate of 540 solar masses per year, but has an order of magnitude less gas and dust than its neighbour and physical conditions akin to those observed in lower-metallicity galaxies in the nearby Universe. These objects suggest the presence of a dark-matter halo with a mass of more than 100 billion solar masses, making it among the rarest dark-matter haloes that should exist in the Universe at this epoch.