Astronomers have discovered thousands of planets outside the Solar System1, most of which orbit stars that will eventually evolve into red giants and then into white dwarfs. During the red giant phase, any close-orbiting planets will be engulfed by the star2, but more distant planets can survive this phase and remain in orbit around the white dwarf3,4. Some white dwarfs show evidence for rocky material floating in their atmospheres5, in warm debris disks6–9 or orbiting very closely10–12, which has been interpreted as the debris of rocky planets that were scattered inwards and tidally disrupted13. Recently, the discovery of a gaseous debris disk with a composition similar to that of ice giant planets14 demonstrated that massive planets might also find their way into tight orbits around white dwarfs, but it is unclear whether these planets can survive the journey. So far, no intact planets have been detected in close orbits around white dwarfs. Here we report the observation of a giant planet candidate transiting the white dwarf WD 1856+534 (TIC 267574918) every 1.4 days. We observed and modelled the periodic dimming of the white dwarf caused by the planet candidate passing in front of the star in its orbit. The planet candidate is roughly the same size as Jupiter and is no more than 14 times as massive (with 95 per cent confidence). Other cases of white dwarfs with close brown dwarf or stellar companions are explained as the consequence of common-envelope evolution, wherein the original orbit is enveloped during the red giant phase and shrinks owing to friction. In this case, however, the long orbital period (compared with other white dwarfs with close brown dwarf or stellar companions) and low mass of the planet candidate make common-envelope evolution less likely. Instead, our findings for the WD 1856+534 system indicate that giant planets can be scattered into tight orbits without being tidally disrupted, motivating the search for smaller transiting planets around white dwarfs.