PROBLEM TO BE SOLVED: To provide a magnetic field sensor which is capable of accurately detecting a gradient magnetic field by sufficiently attenuating a uniform magnetic field.SOLUTION: In a magnetic field sensor 100, a sensor head of a gradiometer 10 includes a first magnetic core 1 supplied with an AC current, a second magnetic core 2 which is separate from the first magnetic core 1 and is supplied with an AC current, a first detection coil 3 wound around the first magnetic core 1, and a second detection coil 4 which is wound around the second magnetic core 2 and is connected backward in series to one end 3a of the first detection coil 3. A sensor head of a magnetometer 20 includes the first magnetic core 1, the second magnetic core 2, a third detection coil 5 wound around the first magnetic core 1, and a fourth detection coil 6 which is wound around the second magnetic core 2 and is connected forward in series to one end of the third detection coil 5.