For defensive purposes, navies use arrays of magnetometers laid across sea floors in strategic locations (i.e. around ports) to monitor submarine activity. The Russian Alfa-class titanium submarines were designed and built at great expense to thwart such systems (as pure titanium is non-magnetic).
Military submarines are degaussed—by passing through large underwater loops at regular intervals—to help them escape detection by sea-floor monitoring systems, magnetic anomaly detectors, and magnetically-triggered mines. However, submarines are never completely de-magnetised. It is possible to tell the depth at which a submarine has been by measuring its magnetic field, which is distorted as the pressure distorts the hull and hence the field. Heating can also change the magnetization of steel.
Submarines tow long sonar arrays to detect ships, and can even recognise different propeller noises. The sonar arrays need to be accurately positioned so they can triangulate direction to targets (e.g. ships). The arrays do not tow in a straight line, so fluxgate magnetometers are used to orient each sonar node in the array.
Fluxgates can also be used in weapons navigation systems, but have been largely superseded by GPS and ring laser gyroscopes.
Magnetometers such as the German Foerster are used to locate ferrous ordnance. Caesium and Overhauser magnetometers are used to locate and help clean up old bombing and test ranges.
UAV payloads also include magnetometers for a range of defensive and offensive tasks.