Peptic ulcer disease and gastric cancer are caused most often by Helicobacter pylori strains that harbor the cag pathogenicity island, which encodes a type IV secretion system (T4SS) that injects the CagA oncoprotein into host cells. cagY is an essential gene in the T4SS and has an unusual DNA repeat structure that predicts in-frame insertions and deletions. These cagY recombination events typically lead to a reduction in T4SS function in mouse and primate models. We examined the role of the immune response in cagY-dependent modulation of T4SS function.H pylori T4SS function was assessed by measuring CagA translocation and the capacity to induce interleukin (IL)8 in gastric epithelial cells. cagY recombination was determined by changes in polymerase chain reaction restriction fragment-length polymorphisms. T4SS function and cagY in H pylori from C57BL/6 mice were compared with strains recovered from Rag1-/- mice, T- and B-cell-deficient mice, mice with deletion of the interferon gamma receptor (IFNGR) or IL10, and Rag1-/- mice that received adoptive transfer of control or Ifng-/- CD4+ T cells. To assess relevance to human beings, T4SS function and cagY recombination were assessed in strains obtained sequentially from a patient after 7.4 years of infection.H pylori infection of T-cell-deficient and Ifngr1-/- mice, and transfer of CD4+ T cells to Rag1-/- mice, showed that cagY-mediated loss of T4SS function requires a T-helper 1-mediated immune response. Loss of T4SS function and cagY recombination were more pronounced in Il10-/- mice, and in control mice infected with H pylori that expressed a more inflammatory form of cagY. Complementation analysis of H pylori strains isolated from a patient over time showed changes in T4SS function that were dependent on recombination in cagY.Analysis of H pylori strains from mice and from a chronically infected patient showed that CagY functions as an immune-sensitive regulator of T4SS function. We propose that this is a bacterial adaptation to maximize persistent infection and transmission to a new host under conditions of a robust inflammatory response.