Gardeners should take extra care when handling old bags of compost after a man died from kidney failure after inhaling poisonous fungal spores, doctors have warned.

The 47-year-old welder from Buckinghamshire, who has not been named, died in intensive care a week after being engulfed by "clouds of dust" when he opened bags of rotting plant material that had been left to fester, in a case reported in the Lancet.

Doctors were baffled by his condition until his partner said he had fallen ill after working in the garden. Later tests revealed he had developed acute aspergillosis, a dangerous reaction to Aspergillus fumigatus spores. The fungus, which is commonly found growing on dead leaves, compost piles and decaying vegetation, may trigger a relatively harmless allergic reaction but can cause serious problems if too many spores get into the lungs.

David Waghorn, a doctor at Wycombe hospital in Buckinghamshire and a microbiologist, said the man had been unlucky: "He'd been opening bags of compost and mulch which had been left to rot. The fungus spores had grown in perfect conditions. He was extremely unlucky - there must have been a very large number of spores which he inhaled."

People with weak immune systems are particularly vulnerable. "What we don't know is how strong his defences were. He was a smoker and a welder by trade and his lungs may have been damaged. It's a very unusual thing to happen but if people are dealing with big bags of mulch, there is a potential danger," said Waghorn.

The man, who had previously been healthy, became ill 24 hours later, but was not admitted to hospital until a week later, when he complained of chest pains and breathing difficulties. Despite being given oxygen by medical staff, tests showed his tissue was starved of oxygen and that he was suffering from "overwhelming sepsis", a life-threatening condition caused by an overactive immune system. Symptoms include a fast heart rate, low blood pressure and kidney problems.

Doctors initially thought he had developed pneumonia from a bacterial infection but treatment with antibiotics was not successful. Once aspergillosis was confirmed, intravenous antifungal drugs were given by doctors, but the treatment came too late.

Waghorn said: "I don't know if he could have been saved had we known about the spores, but we could have given the antifungal drugs sooner."

The authors of the article said that while acute aspergillosis after contact with decayed plant matter is rare, it "may be considered a hazard for gardeners".

In April, a group of German scientists raised concerns about the dangers of airborne mould spores produced when organic waste decayed. The spores could lead to allergic reactions, asthma attacks and hayfever-like symptoms, they said.

Harald Morr, a leading pneumologist, said: "Even just opening the lid of a bin containing organic waste can cause mould spores to be stirred up which, if breathed in, can damage the lungs."

Householders who regularly handled organic waste were advised to wear face masks and to keep a distance when handling rotting material.