The European Journal of Endocrinology study traced antibiotic prescriptions given out to a million UK patients.
The research looked at how many antibiotic prescriptions had been given to 208,000 diabetic patients - both type 1 and type 2 diabetics - at least one year before they were diagnosed with their condition, compared with 816,000 non-diabetic patients of the same age and sex.
Nearly half of the patients had been prescribed antibiotics at some point over the course of the study period. The researchers found the risk of type 2 diabetes went up with the number of antibiotic prescriptions a patient received.
The researchers, Dr Ben Boursi and colleagues from the University of Pennsylvania in the US, believe changes to gut bacteria triggered by taking antibiotics might explain their findings.
Dr Boursi said: "Over-prescription of antibiotics is already a problem around the world as bacteria become increasingly resistant to their effects. "Our findings are important, not only for understanding how diabetes may develop, but as a warning to reduce unnecessary antibiotic treatments that might do more harm than good."
But some say repeated infections could be a sign that diabetes is developing. People with type 2 diabetes are prone to skin and urine infections, for example. Prof Jodi Lindsay from St George's, University of London, said that since people with type 2 diabetes were at increased risk of developing infections, it was hard to tease the two apart.
"This is a very large and helpful study linking diabetes with antibiotic consumption in the UK public, but at this stage we don't know which is the chicken and which is the egg.
"The idea that antibiotics might contribute to diabetes development might be important and more research needs to be done."