  This work aims at studying how magnetic fields affect the observational
properties and the long-term evolution of isolated neutron stars, which are the
strongest magnets in the universe. The extreme physical conditions met inside
these astronomical sources complicate their theoretical study, but, thanks to
the increasing wealth of radio and X-ray data, great advances have been made
over the last years. A neutron star is surrounded by magnetized plasma, the
so-called magnetosphere. Modeling its global configuration is important to
understand the observational properties of the most magnetized neutron stars,
magnetars. On the other hand, magnetic fields in the interior are thought to
evolve on long time-scales, from thousands to millions of years. The magnetic
evolution is coupled to the thermal one, which has been the subject of study in
the last decades. An important part of this thesis presents the
state-of-the-art of the magneto-thermal evolution models of neutron stars
during the first million of years, studied by means of detailed simulations.
The numerical code here described is the first one to consistently consider the
coupling of magnetic field and temperature, with the inclusion of both the
Ohmic dissipation and the Hall drift in the crust.
