Necessity and sufficiency are the building blocks of all successful\nexplanations. Yet despite their importance, these notions have been\nconceptually underdeveloped and inconsistently applied in explainable\nartificial intelligence (XAI), a fast-growing research area that is so far\nlacking in firm theoretical foundations. Building on work in logic,\nprobability, and causality, we establish the central role of necessity and\nsufficiency in XAI, unifying seemingly disparate methods in a single formal\nframework. We provide a sound and complete algorithm for computing explanatory\nfactors with respect to a given context, and demonstrate its flexibility and\ncompetitive performance against state of the art alternatives on various tasks.\n