A magnetic field is a vector field that describes the magnetic influence on moving electric charges, electric currents, and magnetic materials. A moving charge in a magnetic field experiences a force perpendicular to its own velocity and to the magnetic field. A permanent magnet's magnetic field pulls on ferromagnetic materials such as iron, and attracts or repels other magnets. In addition, a nonuniform magnetic field exerts minuscule forces on "nonmagnetic" materials by three other magnetic effects: paramagnetism, diamagnetism, and antiferromagnetism, although these forces are usually so small they can only be detected by laboratory equipment. Magnetic fields surround magnetized materials, electric currents, and electric fields varying in time. Since both strength and direction of a magnetic field may vary with location, it is described mathematically by a function assigning a vector to each point of space, called a vector field.
In electromagnetics, the term "magnetic field" is used for two distinct but closely related vector fields denoted by the symbols B and H. In the International System of Units, the unit of B, magnetic flux density, is the tesla (in SI base units: kilogram per second2 per ampere), which is equivalent to newton per meter per ampere. The unit of H, magnetic field strength, is ampere per meter (A/m). B and H differ in how they take the medium and/or magnetization into account. In vacuum, the two fields are related through the vacuum permeability, ; in a magnetized material, the quantities on each side of this equation differ by the magnetization field of the material.
Magnetic fields are produced by moving electric charges and the intrinsic magnetic moments of elementary particles associated with a fundamental quantum property, their spin. Magnetic fields and electric fields are interrelated and are both components of the electromagnetic force, one of the four fundamental forces of nature.
Magnetic fields are used throughout modern technology, particularly in electrical engineering and electromechanics.