This application discloses novel substituted 2-anilinopyrimidine derivatives, and pharmaceutically acceptable salts, solvates, prodrugs, and compositions thereof, which are useful for the treatment or prevention of diseases or medical conditions mediated by epidermal growth factor receptors (EGFRs), including but not limited to a variety of cancers.