Puccinia graminis f. sp. tritici (Pgt) causes wheat stem rust, a devastating fungal disease. The Sr35 resistance gene confers immunity against this pathogen’s most virulent races, including Ug99. We used comparative whole-genome sequencing of chemically mutagenized and natural Pgt isolates to identify a fungal gene named AvrSr35 that is required for Sr35 avirulence. The AvrSr35 gene encodes a secreted protein capable of interacting with Sr35 and triggering the immune response. We show that the origin of Pgt isolates virulent on Sr35 is associated with the nonfunctionalization of the AvrSr35 gene by the insertion of a mobile element. The discovery of AvrSr35 provides a new tool for Pgt surveillance, identification of host susceptibility targets, and characterization of the molecular determinants of immunity in wheat.