Researchers found that those who used proton pump inhibitor drugs (PPIs) at least once every three months were 44% more likely to develop dementia in later life than those who did not take the drugs.
PPIs are commonly found in heartburn tablets such as omeprazole and lansoprazole. They are often prescribed to treat issues such as acid reflux and stomach ulcers.
The drugs work by blocking the enzyme in the wall of the stomach that produces acid.
Researchers from Germany studied insurance data from 74,000 people aged 75 and over, between 2004 and 2011.
They found that people who used PPIs at least once every three months had a 44% increased risk of developing dementia, compared to those who didn't take the drugs.
The study did have limitations, however, as it only unearthed a "statistical association" between dementia and PPIs, and not a cause-and-effect link.
Co-author of the study, Britta Haenisch, who is from the German Center for Neurodegenerative Diseases in Bonn, said: "To evaluate cause-and-effect relationships between long-term PPI use and possible effects on cognition in the elderly, randomised, prospective clinical trials are needed."
The German researchers, whose findings were published in the journal JAMA Neurology, added that "the avoidance of PPI medication may contribute to the prevention of dementia".
Previous research into PPIs and dementia suggested that people who took the drugs were more likely to be deficient in vitamin B12, which can cause neurological damage.
Dr Helen Webberley, the dedicated GP for Oxford Online Pharmacy, said: "We have known for some time that proton pump inhibitors (PPIs) may have long term health effects, but there is not a well-described causal link with dementia.
"This information is a surprise finding from looking at a lot of data and as such cannot be used to establish a definite cause and effect.
"It does, however, highlight that we are sometimes too willing to pop pills to cure our ills."
She added: "PPIs are a good example of a drug that causes reliance. They are excellent at reducing acid, but when you stop them you get a rebound worsening in acid reflux and indigestion, which makes you want to take them more.
"My advice is to always discuss plans to stop medication with the prescriber, be that your doctor or pharmacist. If you would like to withdraw from PPIs reduce your intake slowly, first by taking them on alternate days and then every three days until your body gets used to the medicine being withdrawn from your system."
Laura Phipps, from Alzheimer’s Research UK, added that the latest study "doesn't tell us definitively that the drugs directly cause the condition".
"There can be many reasons why two factors associate with each other and the next step will be to investigate the possible reasons for this link," she explained.
"Studies like this, which harness large amounts of medical data to highlight trends in health and disease, are incredibly useful to inform future, detailed, follow-up studies into risk factors for conditions like dementia.
"When any drug is taken, doctors, pharmacists and patients have to weigh up the benefits against the potential side effects and further studies into this area will help to better inform these decisions."
Also on HuffPost: