Helicobacter pylori infection causes gastric pathology such as ulcer and carcinoma. Because H. pylori is auxotrophic for cholesterol, we have explored the assimilation of cholesterol by H. pylori in infection. Here we show that H. pylori follows a cholesterol gradient and extracts the lipid from plasma membranes of epithelial cells for subsequent glucosylation. Excessive cholesterol promotes phagocytosis of H. pylori by antigen-presenting cells, such as macrophages and dendritic cells, and enhances antigen-specific T cell responses. A cholesterol-rich diet during bacterial challenge leads to T cell-dependent reduction of the H. pylori burden in the stomach. Intrinsic alpha-glucosylation of cholesterol abrogates phagocytosis of H. pylori and subsequent T cell activation. We identify the gene hp0421 as encoding the enzyme cholesterol-alpha-glucosyltransferase responsible for cholesterol glucosylation. Generation of knockout mutants lacking hp0421 corroborates the importance of cholesteryl glucosides for escaping phagocytosis, T cell activation and bacterial clearance in vivo. Thus, we propose a mechanism regulating the host-pathogen interaction whereby glucosylation of a lipid tips the scales towards immune evasion or response.