In the plant pathogenic fungus Ustilago maydis, sexual and pathogenic development are controlled by the multiallelic b mating-type locus. The b locus encodes a pair of unrelated homeodomain proteins termed bE and bW, with allelic differences clustering in the N-terminal domains of both polypeptides. Only combinations of bE and bW of different allelic origin are active. We have investigated the underlying molecular mechanism for this intracellular self/nonself recognition phenomenon. By using the two-hybrid system, we were able to show that bE and bW dimerize only if they are derived from different alleles. Dimerization involves the N-terminal variable domains. Different point mutants of bE2 were isolated that function in combination with bW2. The majority of such bE2 mutant polypeptides were also able to form heterodimers with bW2 in the two-hybrid system. Nonself-dependent dimerization of bE and bW was supported with a biochemical interaction assay with immobilized proteins. Our results suggest a model for self/nonself recognition in which variable cohesive contacts direct dimerization.