The electrically driven resistance change of metal oxides, called bipolar memristive switching, is a fascinating phenomenon in the development of next-generation nonvolatile memory alternatives to flash technology. However, our understanding of the nature of bipolar memristive switching is unfortunately far from comprehensive, especially the relationship between the electrical transport and the local nonstoichiometry. Here we demonstrate that the coexistence of anion and cation defects is critical to the transport properties of NiO, one of the most promising memristive oxides, by utilizing first-principles calculations. We find that, in the presence of both nickel and oxygen defects, which must exist in any real experimental systems, carrier concentrations of holes generated by nickel defects can be modulated by the presence or absence of oxygen defects around the nickel defect. Such alternation of local nonstoichiometry can be understood in terms of an oxygen ion drift induced by an external electric field. This implication provides a foundation for understanding universally the nature of bipolar memristive switching in various p-type metal oxides.