  In early type galaxies, externally accreted gas is thought to be the main
source of gas replenishment at late times. We use MUSE integral field
spectroscopy data to study the active S0 galaxy NGC 5077, known to have
disturbed dynamics, indicative of a past external interaction. We confirm the
presence of a stellar kinematically distinct core with a diameter of 2.8 kpc,
counter-rotating with respect to the main stellar body of the galaxy. We find
that the counter-rotating core consists of an old stellar population, not
significantly different from the rest of the galaxy. The ionised gas is
strongly warped and extends out to 6.5 kpc in the polar direction and in a
filamentary structure. The gas dynamics is complex, with significant changes in
the position angle as a function of radius. The ionised gas line ratios are
consistent with LINER excitation by the AGN both in the nucleus and at
kiloparsec scales. We discover a nuclear outflow with projected velocity V ~
400 km/s, consistent with a hollow outflow cone intersecting the plan of the
sky. The properties of the misaligned gas match predictions from numerical
simulations of misaligned gas infall after a gas-rich merger. The warp and
change in the gas orientation as a function of radius are consistent with gas
relaxation due to stellar torques, that are stronger at small radii where the
gas aligns faster than in the outer regions, driving gas to the nucleus. The
stellar and gas dynamics indicate that NGC 5077 has had at least two external
interactions, one that resulted in the formation of the counter-rotating core
followed by late time external gas accretion. NGC 5077 illustrates the
importance of external interactions in the replenishment of the galaxy gas
reservoir and the nuclear gas content available for black hole fuelling.
