The findings suggest that some bacterial infections might play a role in triggering heart attacks.
An American study of more than 16,000 British patients showed that people treated with two types of antibiotic had a significantly reduced risk of heart attack.
Those treated with tetracyclines were at 30% less risk than patients not given antibiotics, while those who took quinolones had a 55% reduced risk.
A team led by Dr Christoph Meier, of Boston University Medical Center in Massachusetts, compared the records of 3,315 UK patients who had suffered a first-time heart attack with those of 13,139 with no heart attack history.
The researchers wrote in the Journal of the American Medical Association: "There is increasing evidence from observational studies and randomised clinical trials that certain bacterial infections may play a role in the aetiology (group of conditions that constitute a disease) of coronary heart disease and subsequent myocardial infarction (heart attack)."
In particular, pneumonia caused by the chlamydia organism, Helicobacter pylori, a bacterium linked to stomach ulcers and gum disease, were related to heart attacks and strokes.
No obvious symptoms
Such infections are fairly common and often have mild, or no obvious symptoms at all. Therefore they can go undiagnosed and untreated.
However, the authors cautioned that while the results showed an association they did not prove that bacteria caused heart attacks.
"It must be emphasised that these observational findings should not be interpreted as suggesting that antibiotics should be given to patients to prevent AMI (acute myocardial infarction)," they said.
Former Secretary of the British Hypertension Society, Dr Gordon McInnes, said: "There is a theory that onset of coronary artery disease is due to damage of the blood vessels caused by inflammation that might be down to infection by bacteria.
"Therefore it is feasible that antibiotics might reduce the chance of people developing coronary artery disease and therefore heart attacks."