In [Physical Magazine, 35(3):593-601, 1977], Thouless, Anderson, and Palmer derived a representation for the free energy of the Sherrington-Kirkpatrick model, called the TAP free energy, written as the difference of the energy and entropy on the extended configuration space of local magnetizations with an Onsager correction term. In the setting of mixed $p$-spin models with Ising spins, we prove that the free energy can indeed be written as the supremum of the TAP free energy over the space of local magnetizations whose Edwards-Anderson order parameter (self-overlap) is to the right of the support of the Parisi measure. Furthermore, for generic mixed $p$-spin models, we prove that the free energy is equal to the TAP free energy evaluated on the local magnetization of any pure state.