A methodology for the rigorous nonperturbative derivation of magnetic pseudospin Hamiltonians of mononuclear complexes and fragments based on ab initio calculations of their electronic structure is described. It is supposed that the spin-orbit coupling and other relativistic effects are already taken fully into account at the stage of quantum chemistry calculations of complexes. The methodology is based on the establishment of the correspondence between the ab initio wave functions of the chosen manifold of multielectronic states and the pseudospin eigenfunctions, which allows to define the pseudospin Hamiltonians in the unique way. Working expressions are derived for the pseudospin Zeeman and zero-field splitting Hamiltonian corresponding to arbitrary pseudospins. The proposed calculation methodology, already implemented in the SINGLE_ANISO module of the MOLCAS-7.6 quantum chemistry package, is applied for a first-principles evaluation of pseudospin Hamiltonians of several complexes exhibiting weak, moderate, and very strong spin-orbit coupling effects.