The van der Waals--Casimir-Polder potential is calculated for two atoms out of equilibrium with external thermal electromagnetic field. The effects of absorption and spontaneous or stimulated emission are shown to strongly modify the potential. We demonstrate that the potential decays like ${R}^{\ensuremath{-}2}$ at large distances (much slower than at the equilibrium) can be attractive, repulsive, and resonant depending on the initial states of the atoms and electromagnetic field.