It is shown that defects in certain compounds can be stabilized by the changes they induce in the electronic density of states. This defect-stabilization mechanism is used to explain vacancy formation properties of TiO and TiC. The important contributing factors in the mechanism are: (i) shifts in band mean energies, (ii) changes in bandwidths, (iii) new states associated with the defects, and (iv) the position of the Fermi level. The mechanism, as it applies to vacancies, is illustrated in a two-sublattice compound described by a tight-binding model Hamiltonian. The model is designed to reproduce some of the qualitative features of the TiO electronic structure. The defect states are found to be due to vacancies on the sublattice that would correspond to the O sublattice in TiO. As vacancies are formed, electrons drop into the defect states from the Fermi level, stabilizing the vacancies. The results of realistic Korringa-Kohn-Rostoker average t-matrix approximation cohesive energy calculations for TiO and TiC are presented. These results show that the above mechanism leads to vacancy stabilization in TiO but not in TiC. A square band model of the TiO density of states is used to estimate the relative importance of the four factors in the defect-stabilization mechanism. Parallels with the defect-stabilization mechanism in the transition-metal hydrides are drawn.