Major histocompatibility complex
The major histocompatibility complex (MHC) is a large genomic region or gene family found in most vertebrates. It is the most gene-dense region of the mammalian genome and plays an important role in the immune system, autoimmunity, and reproductive success. The proteins encoded by the MHC are expressed on the surface of cells in all jawed vertebrates, and display both self antigens (peptide fragments from the cell itself) and nonself antigens (e.g. fragments of invading microorganisms) to a type of white blood cell called a T cell that has the capacity to kill or co-ordinate the killing of pathogens, infected or malfunctioning cells.

# Classification
In humans, the 3.6-Mb (3 600 000 base pairs) MHC region on chromosome 6 contains 140 genes between flanking genetic markers MOG and COL11A2.  About half have known immunological functions (see human leukocyte antigen). The same markers in the marsupial Monodelphis domestica (gray short-tailed opossum) span 3.95 Mb and contain 114 genes, 87 shared with humans.

## Subgroups
The MHC region is divided into three subgroups called MHC class I, MHC class II, and MHC class III.
Class III has a very different function than do class I and class II, but it has a locus between the other two (on chromosome 6 in humans), so they are frequently discussed together.

## Responses
The MHC proteins act as "signposts" that display fragmented pieces of an antigen on the host cell's surface. These antigens may be self or nonself. If they are nonself, there are two ways by which the foreign protein can be processed and recognized as being "nonself".
- If the host is a leukocyte, such as a monocyte or neutrophil, it may have engulfed the particle (be it bacterial, viral, or particulate matter), broken it apart using lysozymes, and displayed the fragments on Class II MHC molecules.
- On the other hand, if a host cell was infected by a bacterium or virus, or was cancerous, it may have displayed the antigens on its surface with a Class I MHC molecule. In particular, cancerous cells and cells infected by a virus have a tendency to display unusual, nonself antigens on their surface. These nonself antigens, regardless of which type of MHC molecule they are displayed on, will initiate the specific immunity of the host's body.
It is important to note that cells constantly process endogenous proteins and present them within the context of MHC I.  Immune effector cells are trained not to react to self peptides within MHC, and as such are able to recognize when foreign peptides are being presented during an infection/cancer.

# HLA genes
The best-known genes in the MHC region are the subset that encodes cell-surface antigen-presenting proteins.  In humans, these genes are referred to as human leukocyte antigen (HLA) genes, although people often use the abbreviation MHC to refer to HLA gene products.  To clarify the usage, some of the biomedical literature uses HLA to refer specifically to the HLA protein molecules and reserves MHC for the region of the genome that encodes for this molecule; however this convention is not consistently adhered to.
The most intensely-studied HLA genes are the nine so-called classical MHC genes: HLA-A, HLA-B, HLA-C, HLA-DPA1, HLA-DPB1, HLA-DQA1, HLA-DQB1, HLA-DRA, and HLA-DRB1.  In humans, the MHC is divided into three regions: Class I, II, and III.  The A, B, and C genes belong to MHC class I, whereas the six D genes belong to class II.
Besides being scrutinized by immunologists for its pivotal role in the immune system, the MHC has also attracted the attention of many evolutionary biologists, due to the high levels of allelic diversity found within many of its genes.  Indeed, much theory has been devoted to explaining why this particular region of the genome harbors so much diversity, especially in light of its immunological importance.

# Molecular biology of MHC proteins
The classical MHC molecules (also referred to as HLA molecules in humans) have a vital role in the complex immunological dialogue that must occur between T cells and other cells of the body.  At maturity, MHC molecules are anchored in the cell membrane, where they display short polypeptides to T cells, via the T cell receptors (TCRs).  The polypeptides may be "self," that is, originating from a protein created by the organism itself, or they may be foreign ("nonself"), originating from bacteria, viruses, pollen, etc.  The overarching design of the MHC-TCR interaction is that T cells should ignore self peptides while reacting appropriately to the foreign peptides.
The immune system has another and equally important method for identifying an antigen: B cells with their membrane-bound antibodies, also known as B cell receptors (BCRs).  However, whereas the BCRs of B cells can bind to antigens without much outside help, the TCRs of T cells require "presentation" of the antigen: this is the job of MHC.  It is important to realize that, during the vast majority of the time, MHC are kept busy presenting self-peptides, which the T cells should appropriately ignore.  A full-force immune response usually requires the activation of B cells via BCRs and T cells via the MHC-TCR interaction.  This duplicity creates a system of "checks and balances" and underscores the immune system's potential for running amok and causing harm to the body (see autoimmune disorders).
All MHC molecules receive polypeptides from inside the cells they are part of and display them on the cell's exterior surface for recognition by T cells.  However, there are major differences between MHC class I and MHC class II in the method and outcome of peptide presentation.

# MHC evolution and allelic diversity
MHC gene families are found in essentially all vertebrates, though the gene composition and genomic arrangement vary widely. Chickens, for instance, have  one of the smallest known MHC regions (19 genes), though most mammals have an MHC structure and composition fairly similar to that of humans.
Gene duplication is almost certainly responsible for much of the genetic diversity. In humans, the MHC is littered with many pseudogenes.
One of the most striking features of the MHC, particularly in humans, is the astounding allelic diversity found therein, and especially among the nine classical genes.  In humans, the most conspicuously-diverse loci, HLA-A, HLA-B, and HLA-DRB1, have roughly 250, 500, and 300 known alleles respectively -- diversity truly exceptional in the human genome. The MHC gene is the most polymorphic in the genome.  Population surveys of the other classical loci routinely find tens to a hundred alleles -- still highly diverse. Many of these alleles are quite ancient: it is often the case that an allele from a particular HLA gene is more closely related to an allele found in chimpanzees than it is to another human allele from the same gene.
Phylogenetically the marsupial MHC lies between eutherian mammals and the minimal essential MHC of birds, although it is closer in organization to non-mammals. Its Class I genes have amplified within the Class II region, resulting in a unique Class I/II region.
The allelic diversity of MHC genes has created fertile grounds for evolutionary biologists. The most important task for theoreticians is to explain the evolutionary forces that have created and maintained such diversity. Most explanations invoke balancing selection (see polymorphism (biology)), a broad term that identifies any kind of natural selection in which no single allele is absolutely most fit. Frequency-dependent selection and heterozygote advantage are two types of balancing selection that have been suggested to explain MHC allelic diversity. However, recent models suggest that a high number of alleles is not plausibly achievable through heterozygote advantage alone.  Pathogenic co-evolution, a counter-hypothesis has recently emerged; it theorizes that the most common alleles will be placed under the greatest pathogenic pressure, thus there will always be a tendency for the least common alleles to be positively selected for. This creates a "moving target" for pathogen evolution. As the pathogenic pressure decreases on the previously common alleles, their concentrations in the population will stabilize, and they will usually not go extinct if the population is large enough, and a large number of alleles will remain in the population as a whole. This explains the high degree of MHC polymorphism found in the population, although an individual can have a maximum of 18 MHC I or II alleles.

# MHC and sexual selection
It has been suggested that MHC plays a role in the selection of potential mates, via olfaction. MHC genes make molecules that enable the immune system to recognise invaders; generally, the more diverse the MHC genes of the parents, the stronger the immune system of the offspring. It would obviously be beneficial, therefore, to have evolved systems of recognizing individuals with different MHC genes and preferentially selecting them to breed with.
Yamazaki et al. (1976) showed this to be the case for male mice, who show such a preference for females of different MHC. Similar results have been obtained with fish.
In 1995, Swiss biologist Claus Wedekind determined MHC-dissimilar mate selection tendencies in humans.  In the experiment, a group of female college students smelled t-shirts that had been worn by male students for two nights, without deodorant, cologne or scented soaps. Overwhelmingly, the women preferred the odors of men with dissimilar MHCs to their own. However, their preference was reversed if they were taking oral contraceptives. The hypothesis is that MHCs affect mate choice and that oral contraceptives can interfere with this. A study in 2005 on 58 test subjects showed similar results.