The technologically important incorporation of extrinsic defects ͑Mg 2+ , Fe 2+ , Fe 3+ , Er 3+ , and Nd 3+ ͒ in LiNbO 3 is investigated using density-functional theory combined with thermodynamic calculations. Defect energies, the charge compensation mechanisms, and charge transfer levels, are determined for congruent and stoichiometric compositions. In general, under congruent ͑Nb 2 O 5-rich͒ conditions impurities occupy lithium sites, compensated by lithium vacancies. Under stoichiometric ͑Li 2 O-rich͒ conditions, impurities occupy both lithium and niobium sites. The effects of the concentration of Mg on the dominant defect and site occupancy are analyzed. In addition, the thermal ionization energy and relative defect stability order for Fe 2+ and Fe 3+ are evaluated. The charge transfer levels of impurities with regard to the band structure, and their influences on the optical properties of the material are elucidated.