It only took a billion years or so, but the black holes of two merging galaxies are finally colliding together in a colourful spectacle photographed by NASA’s Hubble Space Telescope.

“Deep inside the dusty, messy cores of merging galaxies are pairs of black holes feasting on material and moving closer to coalescence,” a tweet on the Hubble Telescope twitter account read.

According to NASA, a “galaxy merger” is a slow process that can take more than a billion years to complete.

“Two galaxies, under the inexorable pull of gravity, dance toward each other before finally joining together,” the space agency said in a release. “Simulations reveal that galaxies kick up plenty of gas and dust as they undergo this slow-motion train wreck.”

The Hubble Space Telescope and the W. M. Keck Observatory in Hawaii captured the incredible high-resolution images over a 20-year period.

In the photos, the galaxies’ bright yellow cores can be seen crashing into each other as they’re encased by a cloud of dust and gas in what the researchers call the “final stage” of their union.

“Seeing the pairs of merging galaxy nuclei associated with these huge black holes so close together was pretty amazing," Michael Koss, one of the researchers from Eureka Scientific Inc. who studied the images, said in a release.

The astronomers said black holes grow the most quickly during the final stages of a galaxy merger, which they witnessed in this case.

“The fact that black holes grow faster and faster as mergers progress tells us galaxy encounters are really important for our understanding of how these objects got to be so monstrously big,” researcher Laura Blecha from the University of Florida said.

The images may also provide some insight into another galactic collision that will occur in our own “cosmic backyard” in several billion years when the Milky Way merges with neighbouring Andromeda galaxy, the NASA release said.