Histocompatibility is the property of having the same, or mostly the same, alleles of a set of genes called the major histocompatibility complex. These genes are expressed in most tissues as antigens, to which the immune system makes antibodies. The immune system at first makes antibodies to all sorts of antigens, including those it has never been exposed to, but stops making them to antigens present in the body. If the body is exposed to foreign antigens, as by getting a tissue graft, it attacks the foreign material unless it is histocompatible.
A similar system exists in many plants; its purpose is not to reject grafts, but to prevent inbreeding. Pollen from a plant sharing a histocompatibility gene with the female either fails to grow or dies soon after germinating.