  The local structure and oxidation state of the cobalt impurity in SrTiO$_3$
is studied by X-ray absorption fine structure (XAFS) spectroscopy. The
synthesis conditions, under which cobalt predominantly (up to 76%) substitutes
the atoms at the $A$ site of the perovskite structure, is found for
SrTiO$_3$(Co) samples. By varying the synthesis conditions, it is possible to
appreciably change the ratio between the concentrations of cobalt atoms
incorporated into the $A$ and $B$ sites. It is established that the oxidation
state of cobalt is +2 at the $A$ site and +3 at the $B$ site. It is revealed
that the Co impurity at the $A$ site is off-center, and its displacement from
the lattice site is $\sim$1.0 {\AA}. First-principles calculations show that an
isolated Co$^{3+}$ ion at the $B$ site is diamagnetic, whereas the Co$^{2+}$
ion at the $A$ site is in a high-spin state ($S = 3/2$).
