Blood-thinning drugs may protect against dementia as well as stroke in people with an irregular heartbeat, new research suggests.

A Swedish study found that patients being treated for atrial fibrillation were less likely to develop dementia if they were taking anticoagulants.

Their risk was reduced by up to 48% compared with others with the same condition who were not prescribed the drugs.

The study, published in the European Heart Journal, found no difference in dementia prevention between the older blood-thinning drug warfarin and newer anticoagulants.

Researchers found that of 444,106 patients in Sweden who had atrial fibrillation, an abnormal heart condition that can provoke strokes, those taking drugs to prevent blood clots had a 29% lower risk of developing dementia.

The risk further decreased as patients continued to take the medication.

The study is the largest ever on the link between anticoagulants and dementia in atrial fibrillation patients.

The strong link with dementia suggests blood thinners are responsible for lowering risk, but clinical trials would be needed to establish cause-and-effect, the scientists said. There is, however, a catch.

"Such studies cannot be done because of ethical reasons," said lead author Leif Friberg, a researcher at the Karolinska Institute in Stockholm.

"It is not possible to give placebo to atrial fibrillation patients and then wait for dementia or stroke to occur."

Scientists had speculated that anticoagulants might stave off dementia because they prevent tiny clots that can cause unnoticed microscopic strokes, a major contributor to cognitive decline.

Researchers identified all patients in Sweden diagnosed with atrial fibrillation between 2006 and 2014.

They then checked on what drugs had been prescribed, and followed the patients' progress.

When they first joined the study, 54% of patients were not taking oral anticoagulants such as warfarin or apixaban.

The researchers found that the strongest predictors for dementia were lack of oral anticoagulant treatment, ageing, Parkinson's disease and alcohol abuse.

They also found that the sooner oral anticoagulant treatment was started after a diagnosis of atrial fibrillation, the greater the protective effect against dementia.

Friberg said patients should be started on blood-thinners immediately after diagnosis, and continue taking the medication.

"Doctors should not tell their patients to stop using oral anticoagulants without a really good reason," he said in a statement.

An alarmingly high per centage of patients stop taking their medication after a few years, he added.

"In the first year, approximately 15% stop taking the drugs, then approximately 10% each year."