Methicillin-resistant Staphylococcus aureus (MRSA) is a frequent cause of difficult-to-treat, often fatal infections in humans1,2. Most humans have antibodies against S. aureus, but these are highly variable and often not protective in immunocompromised patients3. Previous vaccine development programs have not been successful4. A large percentage of human antibodies against S. aureus target wall teichoic acid (WTA), a ribitol-phosphate (RboP) surface polymer modified with N-acetylglucosamine (GlcNAc)5,6. It is currently unknown whether the immune evasion capacities of MRSA are due to variation of dominant surface epitopes such as those associated with WTA. Here we show that a considerable proportion of the prominent healthcare-associated and livestock-associated MRSA clones CC5 and CC398, respectively, contain prophages that encode an alternative WTA glycosyltransferase. This enzyme, TarP, transfers GlcNAc to a different hydroxyl group of the WTA RboP than the standard enzyme TarS7, with important consequences for immune recognition. TarP-glycosylated WTA elicits 7.5-40-fold lower levels of immunoglobulin G in mice than TarS-modified WTA. Consistent with this, human sera contained only low levels of antibodies against TarP-modified WTA. Notably, mice immunized with TarS-modified WTA were not protected against infection with tarP-expressing MRSA, indicating that TarP is crucial for the capacity of S. aureus to evade host defences. High-resolution structural analyses of TarP bound to WTA components and uridine diphosphate GlcNAc (UDP-GlcNAc) explain the mechanism of altered RboP glycosylation and form a template for targeted inhibition of TarP. Our study reveals an immune evasion strategy of S. aureus based on averting the immunogenicity of its dominant glycoantigen WTA. These results will help with the identification of invariant S. aureus vaccine antigens and may enable the development of TarP inhibitors as a new strategy for rendering MRSA susceptible to human host defences.