A method for the ab initio prediction of the EPR g tensor for paramagnetic defects in systems under periodic boundary conditions is presented. It is based on density functional theory and the pseudopotential approximation. The formalism is applicable to crystalline and amorphous insulators, as well as to isolated molecules using a supercell technique. The method is validated by comparison with a well-established theoretical approach and experimental data for a series of small isolated molecules. Finally the EPR parameters of an O3− defect in a KCl lattice are evaluated following the new procedure, yielding results in good agreement with experiment and at an attractive computational cost.