Stem rust caused by the fungus Puccinia graminis f. sp. tritici (Pgt) is a devastating disease of the global staple crop wheat. Although this disease was largely controlled in the latter half of the twentieth century, new virulent strains of Pgt, such as Ug99, have recently evolved1,2. These strains have caused notable losses worldwide and their continued spread threatens global wheat production. Breeding for disease resistance provides the most cost-effective control of wheat rust diseases3. A number of rust resistance genes have been characterized in wheat and most encode immune receptors of the nucleotide-binding leucine-rich repeat (NLR) class4, which recognize pathogen effector proteins known as avirulence (Avr) proteins5. However, only two Avr genes have been identified in Pgt so far, AvrSr35 and AvrSr50 (refs. 6,7), and none in other cereal rusts8,9. The Sr27 resistance gene was first identified in a wheat line carrying an introgression of the 3R chromosome from Imperial rye10. Although not deployed widely in wheat, Sr27 is widespread in the artificial crop species Triticosecale (triticale), which is a wheat–rye hybrid and is a host for Pgt11,12. Sr27 is effective against Ug99 (ref. 13) and other recent Pgt strains14,15. Here, we identify both the Sr27 gene in wheat and the corresponding AvrSr27 gene in Pgt and show that virulence to Sr27 can arise experimentally and in the field through deletion mutations, copy number variation and expression level polymorphisms at the AvrSr27 locus.