All permanent magnets (materials that can be magnetized by an external magnetic field and which remain magnetized after the external field is removed) are either ferromagnetic or ferrimagnetic, as are the metals that are noticeably attracted to them.
Historically, the term ferromagnet was used for any material that could exhibit spontaneous magnetization: a net magnetic moment in the absence of an external magnetic field. This general definition is still in common use. More recently, however, different classes of spontaneous magnetization have been identified when there is more than one magnetic ion per primitive cell of the material, leading to a stricter definition of "ferromagnetism" that is often used to distinguish it from ferrimagnetism. In particular, a material is "ferromagnetic" in this narrower sense only if all of its magnetic ions add a positive contribution to the net magnetization. If some of the magnetic ions subtract from the net magnetization (if they are partially anti-aligned), then the material is "ferrimagnetic". If the ions anti-align completely so as to have zero net magnetization, despite the magnetic ordering, then it is an antiferromagnet. All of these alignment effects only occur at temperatures below a certain critical temperature, called the Curie temperature (for ferromagnets and ferrimagnets) or the Néel temperature (for antiferromagnets).
Ferromagnetism is a property not just of the chemical makeup of a material, but of its crystalline structure and microscopic organization. There are ferromagnetic metal alloys whose constituents are not themselves ferromagnetic, called Heusler alloys, named after Fritz Heusler.
One can also make amorphous (non-crystalline) ferromagnetic metallic alloys by very rapid quenching (cooling) of a liquid alloy. These have the advantage that their properties are nearly isotropic (not aligned along a crystal axis); this results in low coercivity, low hysteresis loss, high permeability, and high electrical resistivity. A typical such material is a transition metal-metalloid alloy, made from about 80% transition metal (usually Fe, Co, or Ni) and a metalloid component (B, C, Si, P, or Al) that lowers the melting point.
A relatively new class of exceptionally strong ferromagnetic materials are the rare-earth magnets. They contain lanthanide elements that are known for their ability to carry large magnetic moments in well-localized f-orbitals.
The spin of an electron, combined with its orbital angular momentum, results in a magnetic dipole moment and creates a magnetic field. (The classical analogue of quantum-mechanical spin is a spinning ball of charge, but the quantum version has distinct differences, such as the fact that it has discrete up/down states that are not described by a vector; similarly for "orbital" motion, whose classical analogue is a current loop.) In many materials (specifically, those with a filled electron shell), however, the total dipole moment of all the electrons is zero (i.e., the spins are in up/down pairs). Only atoms with partially filled shells (i.e., unpaired spins) can experience a net magnetic moment in the absence of an external field. Ferromagnetic materials contain many atoms with unpaired spins. When these tiny magnetic dipoles are aligned in the same direction, they create a measurable macroscopic field.
These permanent dipoles (often called simply "spins" even though they also generally include orbital angular momentum) tend to align in parallel to an external magnetic field, an effect called paramagnetism. (A related but much weaker effect is diamagnetism, due to the orbital motion induced by an external field, resulting in a dipole moment opposite to the applied field.) Ferromagnetism involves an additional phenomenon, however: the dipoles tend to align spontaneously, without any applied field. This is a purely quantum-mechanical effect.
According to classical electromagnetism, two nearby magnetic dipoles will tend to align in opposite directions (which would create an antiferromagnetic material). In a ferromagnet, however, they tend to align in the same direction because of the Pauli principle: two electrons with the same spin cannot also have the same "position", which effectively reduces the energy of their electrostatic interaction compared to electrons with opposite spin. (Mathematically, this is expressed more precisely in terms of the spin-statistics theorem: because electrons are fermions with half-integer spin, their wave functions are antisymmetric under interchange of particle positions. This can be seen in, for example, the Hartree-Fock approximation to lead to a reduction in the electrostatic potential energy.) This difference in energy is called the exchange energy.
At long distances (after many thousands of ions), the exchange energy advantage is overtaken by the classical tendency of dipoles to anti-align. This is why, in an equilibriated (non-magnetized) ferromagnetic material, the dipoles in the whole material are not aligned. Rather, they organize into magnetic domains (also known as Weiss domains) that are aligned (magnetized) at short range, but at long range adjacent domains are anti-aligned. The boundary between two domains, where the magnetization flips, is called a domain wall (i.e., a Bloch/Néel wall, depending upon whether the magnetization rotates parallel/perpendicular to the domain interface) and is a gradual transition on the atomic scale (covering a distance of about 300 ions for iron).
Thus, an ordinary piece of iron generally has little or no net magnetic moment. However, if it is placed in a strong enough external magnetic field, the domains will re-orient in parallel with that field, and will remain re-oriented when the field is turned off, thus creating a "permanent" magnet. The domains don't go back to their original minimum energy configuration when the field is turned off because the domain walls tend to become 'pinned' or 'snagged' on defects in the crystal lattice, preserving their parallel orientation. This magnetization as a function of the external field is described by a hysteresis curve. Although this state of aligned domains is not a minimal-energy configuration, it is extremely stable and has been observed to persist for millions of years in seafloor magnetite aligned by the Earth's magnetic field (whose poles can thereby be seen to flip at long intervals). Alloys used for the strongest permanent magnets are "hard" alloys made with many defects in their crystal structure where the domain walls "catch" and stabilize. The net magnetization can be destroyed by heating and then cooling (annealing) the material without an external field, however. The thermal motion allows the domain boundaries to move, releasing them from any defects, to return to their low-energy unaligned state.
The study of ferromagnetic phase transitions, especially via the simplified Ising spin model, had an important impact on the development of statistical physics. There, it was first clearly shown that mean field theory approaches failed to predict the correct behavior at the critical point (which was found to fall under a universality class that includes many other systems, such as liquid-gas transitions), and had to be replaced by renormalization group theory.