The naturally competent organism Helicobacter pylori encodes a large number of restriction–modification (R–M) systems that consist of a restriction endonuclease and a DNA methyltransferase. R–M systems are not only believed to limit DNA exchange among bacteria but may also have other cellular functions. We report a previously uncharacterized H. pylori type II R–M system, M.HpyAXII/R.HpyAXII. We show that this system targets GTAC sites, which are rare in the H. pylori chromosome but numerous in ribosomal RNA genes. As predicted, this type II R–M system showed attributes of a selfish element. Deletion of the methyltransferase M.HpyAXII is lethal when associated with an active endonuclease R.HpyAXII unless compensated by adaptive mutation or gene amplification. R.HpyAXII effectively restricted both unmethylated plasmid and chromosomal DNA during natural transformation and was predicted to belong to the novel ‘half pipe’ structural family of endonucleases. Analysis of a panel of clinical isolates revealed that R.HpyAXII was functional in a small number of H. pylori strains (18.9%, n=37), whereas the activity of M.HpyAXII was highly conserved (92%, n=50), suggesting that GTAC methylation confers a selective advantage to H. pylori. However, M.HpyAXII activity did not enhance H. pylori fitness during stomach colonization of a mouse infection model.