Abstract. A general theory of the Casimir-Polder interaction of single atoms with dispersing and absorbing magnetodielectric bodies is presented, which is based on QED in linear, causal media. Both ground-state and excited atoms are considered. Whereas the Casimir-Polder force acting on a ground-state atom can conveniently be derived from a perturbative calculation of the atom-field coupling energy, an atom in an excited state is subject to transient force components that can only be fully understood by a dynamical treatment based on the body-assisted vacuum Lorentz force. The results show that the Casimir-Polder force can be influenced by the body-induced broadening and shifting of atomic transitions-an effect that is not accounted for within lowest-order perturbation theory. The theory is used to study the Casimir-Polder force of a ground-state atom placed within a magnetodielectric multilayer system, with special emphasis on thick and thin plates as well as a planar cavity consisting of two thick plates. It is shown how the competing attractive and repulsive force components related to the electric and magnetic properties of the medium, respectively, can-for sufficiently strong magnetic properties-lead to the formation of potential walls and wells.PACS. 12.20.-m Quantum electrodynamics -34.50.Dy Interactions of atoms and molecules with surfaces -42.50.Nn Quantum optical phenomena in absorbing, dispersive, and conducting media