Optical initialization of the negatively charged nitrogen-vacancy (NV$^-$) center in diamond makes it one of the best candidates for realization of addressable spins in the solid state for quantum computing and other studies. However, its exact mechanism was not clear. We show that exact diagonalization of a many-electron Hamiltonian with parameters derived from ab initio GW calculations puts strong constraints on the mechanism. The energy surfaces of the low-energy many-body states and the relaxation processes of photoexcitation responsible for the optical initialization are calculated. Intersystem crossings are shown to be essential.