In physics, particularly in magnetism, the magnetic field is a solenoidal vector field generated in space by the motion of an electric charge or a time-varying electric field. Together with the electric field, the magnetic field constitutes the electromagnetic field, responsible for electromagnetic interaction in space.
Actually, the equations related to the electric field and those related to the magnetic field, are separated only in appearance, since it is the electric charges themselves that in motion (as electric current) give rise to the magnetic field.
However, since the fact that electric charges are stationary or in motion, is relative (i.e. dependent on the reference system chosen to describe the phenomenon), becomes equally relative the fact that we are dealing with an electric field or a magnetic field. So it is natural to interpret electric field and magnetic field as different manifestations of a single physical entity, called electromagnetic field.
The discovery of the production of magnetic fields by conductors crossed by electric current is due to Ørsted in 1820: experimentally it is verified that the direction of the field is the direction indicated by the equilibrium position of the needle of a compass immersed in the field; the instrument for measuring the magnetic field is the magnetometer.
The magnetic field acts on an electrically charged object by the Lorentz force (in the case of an electric charge in motion) or by the torque acting on a magnetic dipole. The spatial and temporal evolution of the magnetic field is governed by Maxwell’s equations, a system of four linear partial differential equations that form the basis of the formal description of electromagnetic interaction.