Researchers have developed the first breath test for TB in the laboratory.
It provides rapid information on drug resistance that takes up to six weeks using standard methods, US scientists report in the journal, Nature Communications.
The bacteria emit a unique gas signature within 10 minutes of exposure to an inhaled antibiotic in rabbits.
TB infects 8.6m people each year worldwide and kills 1.3m, second only to HIV.
Early diagnosis and treatment are a priority in the global fight against TB, according to the World Health Organization.
The new research used an inhaled form of isoniazid - an antibiotic commonly used to treat the disease - which is activated by a TB enzyme.
The test exploits the fact that this enzyme is unique to TB, said Dr Graham Timmins, Associate Professor at the University of New Mexico, US, who led the research.
"We realised that we could actually look at the conversion of isoniazid to its active form by monitoring one of the labelled gases that's given off during its activation," he explained.
The researchers gave a special molecularly-labelled form of isoniazid to laboratory rabbits.
In the presence of TB, labelled nitrogen gas was released from the lungs and detected by a machine called a mass spectrometer.
A positive result indicates that TB bugs are present and suggests they are susceptible to isoniazid.
TB is very difficult to treat, requiring at least six months of treatment with multiple drugs.
Childhood TB can be harder to detect than the adult form of the disease
The test could be particularly useful in children where sputum samples are problematic
Failure to complete treatment has contributed to the rise of multidrug-resistant TB (MDR-TB), accounting for 30% of cases in some countries.
For many years diagnosis of TB relied on a lengthy wait for the bacteria to grow in a culture of the patient's sputum.
"If you do it by culture, it can take a month to six weeks before you get a result," said Dr Timmins.
In the last few years a new DNA detection technique called GeneXpert has been endorsed by the World Health Organization.
From a sample of sputum it can detect whether a sample contains TB and whether it is is resistant to one of the key drugs, rifampicin, in about three hours.
But for full drug resistance information the patient has to wait longer.
"Optimally treating somebody the best you can at the time of that single encounter, so someone can go home with the right set of tablets, would be really, really useful," said Dr Timmins.
The new breath test samples the whole lung for what is hoped will be greater sensitivity, in a wider range of patients, with results available almost instantly.
"It's a clever idea," said Dr Ruth McNerney, senior lecturer at the London School of Hygiene and Tropical Medicine.
The test could "add a bit more certainty" to the diagnosis of MDR-TB, and "it's worth pursuing, definitely," she said.
At present the breath test only detects isoniazid sensitivity. It will therefore need to be used in combination with other tests.
"This is just the start of the program we want to instigate," said Dr Timmins.
The next step will be to show that the tests work in humans in a clinical setting.
"Lots of good ideas fail when you put them into the clinic," conceded Dr Timmins.