To explore Helicobacter pylori (Hp) infection status and its relationship with lifestyle habits and dietary factors in patients with chronic atrophic gastritis. Six hundred thirty-eight patients with chronic atrophic gastritis, who were admitted to our hospital from March 2021 to April 2023, were selected for the study. All patients underwent the 13C urea breath test. The relationship between the detection rate of Hp infection and the clinical characteristics, lifestyle habits, and dietary factors of the patients was analyzed. Among the 638 patients with chronic atrophic gastritis, 531 patients were tested positive for Hp infection, the positive rate for Hp infection was approximately 83.23%. Analyzing the clinical characteristics of the patients, it was found that age, family history of gastric cancer, degree of chronic inflammation, degree of glandular atrophy, presence of low-grade dysplasia, and intestinal metaplasia all have an impact on the positive detection rate of patients (P < .05). Analyzing the patients’ lifestyle habits, it was found that BMI, smoking history, alcohol consumption, preference for spicy food, dining location, consumption of pickled foods, frequent consumption of grilled/barbecued foods, preference for strong tea, consumption of sweets, and work-related stress had an impact on the positive rate of Hp infection in patients (P < .05). The discovery showed that the levels of total protein, albumin, hemoglobin, cholesterol, and the intake of livestock and poultry meat, seafood, dairy products, vegetables, fruits, and fats have an impact on the positivity rate of Hp infection in patients (P < .05). A multiple logistic regression analysis was performed, and it was found that patients’ age, family history of gastric cancer, degree of chronic inflammation, degree of glandular atrophy, presence of low-grade dysplasia, presence of wasting or obesity, history of alcohol consumption, preference for spicy food, dining location, frequent consumption of strong tea, high work pressure, high intake of fish and seafood, low intake of dairy products, low intake of vegetables, low intake of fruits, and low intake of fats all had an impact on the occurrence of Hp infection in patients (P < .05). There is a certain correlation between patients’ lifestyle habits, dietary factors, and clinical characteristics with the occurrence of Hp infection. These factors can assist in the prevention of Hp infection.