  Topological materials have drawn increasing attention owing to their rich
quantum properties. A notable highlight is the observation of a large intrinsic
anomalous Hall effect (AHE) in Weyl and nodal-line semimetals. However, how the
electronic topology of the carriers contributes to the transport and whether it
can be externally tuned remains elusive. In this study, we demonstrate a
magnetic-field-induced switching of band topology in $\alpha$-EuP$_3$, a
magnetic semimetal with a layered crystal structure derived from black
phosphorus. Such topology switching is shown to be accompanied by a crossover
from paramagnetic to ferromagnetic, manifesting as a giant AHE in the
magnetoresistance when the magnetic field is perpendicular to the crystalline
mirror plane. Electronic structure calculations further indicate that,
depending on the direction of the magnetic field, two distinct topological
phases, Weyl semimetal and topological nodal-line semimetal, are stabilized via
the exchange coupling between Eu-4$f$ moments and conducting carriers. Our
findings provide a realistic solution for external control and manipulation of
band topology, enriching the functional aspects of topological materials and
furthering the possibility of practical applications for topological
electronics.
