Dimers are the smallest chemical objects that show magnetic anisotropy. We focus on 3d and 4d transition metal dimers that have magnetic ground states in most cases. Some of these magnetic dimers have a considerable barrier against re-orientation of their magnetization, the so-called magnetic anisotropy energy, MAE. The height of this barrier is important for technological applications, as it determines, e.g., the stability of information stored in magnetic memory devices. It can be estimated by means of relativistic density functional calculations. Our approach is based on a full-potential local-orbital method (FPLO) in a four-component Dirac-Kohn-Sham implementation. Orbital polarization corrections to the local density approximation are employed. They are discussed in the broader context of orbital dependent density functionals. Ground state properties (spin multiplicity, bond length, harmonic vibrational frequency, spin- and orbital magnetic moment, and MAE) of the 3d and 4d transition metal dimers are evaluated and compared with available experimental and theoretical data. We find exceptionally high values of MAE, close to 0.2 eV, for four particular dimers: Fe(2), Co(2), Ni(2), and Rh(2).