The quantum anomalous Hall effect (QAHE) has recently been reported to emerge in magnetically doped topological insulators. Although its general phenomenology is well established, the microscopic origin is far from being properly understood and controlled. Here, we report on a detailed and systematic investigation of transition metal (TM) doped Sb2Te3. By combining density functional theory calculations with complementary experimental techniques, i.e., scanning tunneling microscopy, resonant photoemission, and x-ray magnetic circular dichroism, we provide a complete spectroscopic characterization of both electronic and magnetic properties. Our results reveal that the TM dopants not only affect the magnetic state of the host material, but also significantly alter the electronic structure by generating impurity-derived energy bands. Our findings demonstrate the existence of a delicate interplay between electronic and magnetic properties in TM doped topological insulators. In particular, we find that the fate of the topological surface states critically depends on the specific character of the TM impurity: while V- and Fe-doped Sb2Te3 display resonant impurity states in the vicinity of the Dirac point, Cr and Mn impurities leave the energy gap unaffected. The single-ion magnetic anisotropy energy and easy axis, which control the magnetic gap opening and its stability, are also found to be strongly TM impurity dependent and can vary from in plane to out of plane depending on the impurity and its distance from the surface. Overall, our results provide general guidelines for the realization of a robust QAHE in TM doped Sb2Te3 in the ferromagnetic state.