  Simulations and observations find 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. While at larger
distances from the galaxy, they 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 magneto-hydrodynamical windtunnel
simulations of a galaxy with the arepo code to study the origin of gas in the
tails of jellyfish galaxies. To this end, we model the galaxy orbit in a
cluster by accounting for a time-varying galaxy velocity, ICM density and
turbulent magnetic field. Tracking gas flows between the ISM, the
circumgalactic medium (CGM) and the ICM, we find contrary to popular opinion
that the majority of gas in the tail originated 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 was accreted to 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.
