A considerable number of animals, including bacteria, arthropods, molluscs and mammals are known to be able to sense magnetic fields.
For some varieties of bacteria, known as Magnetotactic bacteria, the ability is now quite well explained. But for mammals and birds, for example, there are currently no agreed explanations.
“The largest issue affecting verification of an animal magnetic sense is that despite more than 40 years of work on magnetoreception there has yet to be an identification of a sensory receptor. Given that the entire receptor system could likely fit in a one-millimeter cube and have a magnetic content of less than one ppm, it is difficult to discern the parts of the brain where this information is processed.”
See Magnetoreception at Wikipedia.
Also see: Pigeon navigation