A magnetic field is generated when electric charge carriers such as electrons move through space or within an electrical conductor. The geometric shapes of the magnetic flux lines produced by moving charge carriers (electric current) are similar to the shapes of the flux lines in an electrostatic field.

The term is used for two distinct but closely related fields denoted by the symbols B and H, where H is measured in units of amperes per meter (symbol: A·m−1 or A/m) in the SI. B is measured in teslas (symbol:T; note that although the symbol is capital T, "tesla" is written in lower case in the SI system) and newtons per meter per ampere (symbol: N·m−1·A−1 or N/(m·A)) in the SI. B is most commonly defined in terms of the Lorentz force it exerts on moving electric charges.