Simulations and observations have found long tails in `jellyfish galaxies', which are commonly thought to originate from ram-pressure stripped gas of the interstellar medium (ISM) in the immediate galactic wake. At larger distances from the galaxy, the long tails have been claimed to form in situ, owing to thermal instability and fast radiative cooling of mixed ISM and intracluster medium (ICM). In this paper, we use magnetohydrodynamical wind tunnel simulations of a galaxy with the arepo code to study the origin of gas in the tails of jellyfish galaxies. To this end, we modelled the galaxy orbit in a cluster by accounting for a time-varying galaxy velocity, ICM density, and the turbulent magnetic field. By tracking gas flows between the ISM, the circumgalactic medium (CGM), and the ICM, we find -- contrary to popular opinion -- that the majority of the gas in the tail originates in the CGM. Prior to the central passage of the jellyfish galaxy in the cluster, the CGM is directly transported to the clumpy jellyfish tail that has been shattered into small cloudlets. After the central cluster passage, gas in the tail originates both from the initial ISM and the CGM, but that from the latter is accreted onto the galactic ISM before being ram-pressure stripped to form filamentary tentacles in the tail. Our simulation shows a declining gas metallicity in the tail as a function of downstream distance from the galaxy. We conclude that the CGM plays an important role in shaping the tails of jellyfish galaxies.