Tests on 22 brands of compost available in the UK found almost two-thirds - a total of 14 - contained a variety of legionella bugs. Four showed evidence of legionella longbeachae, which can cause serious infections lead to death or require hospital treatment.
The report by Strathclyde University experts is the first comprehensive study of composts in the UK and comes as five people have been affected in a spate of legionella longbeachae infections in Scotland.
The outbreak led to health experts recommending warning labels be put on compost bags and the new report suggests that move may be beneficial in protecting public health.
Dr Tara Beattie, from Strathclyde University, who led the research, said: "Disease causing micro-organisms are widespread in the environment, and therefore it is not too surprising that species of legionella that can cause human disease are present in compost.
"Any environment where you have pathogenic bacteria could be a source of infection, and we already know compost has been linked to human legionella infection in countries such as Australia and New Zealand.
"Within the UK and across Europe composts have traditionally been composed of peat, whereas sawdust and bark are more often used to produce compost in Australia and New Zealand where legionellosis associated with compost is more common.
"It may be the change in composition of composts in the UK could be resulting in species such as legionella longbeachae being present in compost and therefore more cases of infection could occur."
Health Protection Scotland (HPS) launched an investigation into what it described as an uncommon number of cases of legionella after a fifth victim was identified in Tayside. The first four cases, two of whom were treated in intensive care, were reported in the Lothians area.
Gardeners are being warned to take precautions, including wearing gloves and a dust mask and washing their hands.
Dr Beattie said: "A larger-scale survey, covering a wider range of compost products is required to determine if these organisms, some disease causing, some not, are as widespread in composts as this initial study would suggest.
"It should be emphasised that, although legionella seem to be common in compost, human infection is very rare, especially if you consider the volume of compost sold and used.
"But, with any potential source of infection, precautions should always be taken.."
The findings are reported in the journal Clinical Microbiology and Infection.
l NHS Ayrshire and Arran said yesterday a third person was being treated for Legionnaires' disease. The cases do not appear to be linked and all patients are recovering well, the health board said.