Researchers interviewed 2,000 people selected randomly in the Kuopio and Joensuu regions of eastern Finland in the 1970s and 80s, when their average age was 50.4 years.
A total of 1,409 of the volunteers were then re-examined in 1998 for cognitive impairment, when their ages ranged from 65-79.
Of these, 57 were diagnosed with Alzheimer's disease or other forms of dementia; 82 had mild cognitive impairment; the remaining 1,270 were otherwise healthy.
"People living without a partner at mid-life had around twice the risk of developing cognitive impairment in later life compared with people living with a partner," the study found.
The risk was roughly triple among those who had been widowed or divorced in mid-life and were not living in partnership in later life.
Education, smoking habits and other variables that are known to affect cognitive impairment were all taken into account.
The investigators found a big difference between the sexes.
Compared with co-habitants, men who lived alone in mid-life were two and a half times likelier to develop cognitive impairment later in life. The risk for women, though, was 1.87 times.
They also found a powerful link between Alzheimer's, living alone and a variant of a gene called apolipoprotein E-e4 which makes a protein associated with this disorder.
The paper, headed by Miia Kivipelto, an associate professor in ageing research at Sweden's Karolinska Institute, is published online by the British Medical Journal (BMJ).
Living with a partner "might imply cognitive and social challenges" that help shield against dementia, but why this could be so has to be explained, the authors say.
In 2005 an estimated 25 million people had dementia, and the tally is expected to reach 81.1 million in 2040, according to figures quoted in the study.