According to an embodiment of the present invention, a magnetic field sensor is provided with: a magnetic field sense circuit (11) that is provided with a ferromagnetic element (15) wherein a resistance value changes due to a magnetic field and an electric field, and an electrode (31) to which a control voltage (Vcontrol) for generating the electric field is applied; a resistance detection circuit (12) that detects the resistance value of the ferromagnetic element (15); and a control voltage generation circuit (10) that generates the control voltage. The control voltage generation circuit (10) generates the control voltage (Vcontrol) that makes the resistance value of the ferromagnetic element (15) at a predetermined value when the magnetic field is zero.