Background: Recently, an increasing number of studies have focused on the extra-gastrointestinal effects of Helicobacter pylori (H. pylori), including metabolic syndrome, fatty liver, and rheumatic and skin diseases. Osteoporosis is an asymptomatic disease that can eventually lead to fractures and has a significant impact on the quality of life of elderly individuals. Sex is an influential factor that plays a crucial role in the development of osteoporosis. The aim of this study was to investigate the relationship between H. pylori infection and osteoporosis and to identify potential influencing factors. Methods: We conducted a cross-sectional study of individuals older than 50 years old, who had undergone regular physical examinations at the Beijing Shijitan Hospital Health Examination Center from July to October 2018. We evaluated the associations of osteopenia and osteoporosis with H. pylori infection and related serum markers by using multiple linear regression and logistic regression. Then, we analysed the correlation between sex and potential serum biomarkers. Results: There were significant relationships between H. pylori infection status and bone density in premenopausal females but not in males (P = 0.381) according to Fisher's exact test. In females, H. pylori positivity (OR = 0.132, P = 0.023), Body Mass Index (BMI) (OR = 28.163, P = 0.021), and homocysteine (HCY) (OR = 17.218, P = 0.045) were associated with osteoporosis. Calcium had a trend but no statistically significant (OR = 0.060, P = 0.076) relationship with osteoporosis. Furthermore, the waist-to-hip ratio (OR = 5.783, P = 0.029), BMI (OR = 0.152, P = 0.014) and triglyceride levels (OR = 0.201, P = 0.036) were significantly different by sex, after adjusting for age as a confounder. Conclusion: H. pylori positivity, BMI and HCY are associated with osteoporosis in premenopausal females. Chronic inflammation may be involved in the relationship between H. pylori and osteoporosis.