A magnetic sensor that is inexpensive and suppresses changes in offset voltage caused by wear. The magnetic sensor includes magnetoresistance elements having electrical resistances that change in accordance with magnetism changes. The magnetic sensor detects magnetism based on changes in the electrical resistances. The magnetoresistance elements are covered by a protective film. Part of the protective film is etched and eliminated to form a recess.