A new blood test can help doctors tease out whether an infection is caused by a virus or bacteria within two hours, research in Plos One suggests.
It could stop patients being given antibiotics when they are not needed, scientists say.
It is still at a laboratory stage but the team is working on a portable device too.
Independent experts say the work addresses a serious problem. Further studies are being carried out.
Doctors face a number of challenges when deciphering which bug is responsible for an infection and the treatment that would best tackle it.
Routine tests to check the definitive identity of bugs can take days - they often involve taking a sample and then trying to grow the organism in a lab.
Tests of particles in the blood can also help give clues, but some are raised in both bacterial and viral infections and in cancer and trauma too.
As a result sometimes antibiotics - which only work on bacteria - are overused.
And in contrast some patients who need antibiotics don't get them soon enough.
The team of scientists from several medical centres in Israel, in collaboration with the company MeMed, developed the new test.
Analyzing blood samples of more than 300 patients who were suspected of having an infection, they found it could correctly detect a virus or a bacterial infection in the majority of cases.
Eran Eden, of MeMed said: "The test is accurate. For most patients you can tell whether the infection was caused by bacteria or a virus within two hours.
"It is not perfect and it does not replace a physician's judgement, but it is better than many of the routine tests used in practice today."
It relies on the fact that bacteria and viruses can trigger different protein pathways once they infect the body.
A novel one, called TRAIL, was particularly high in viral infections and depleted during bacterial ones. They combined this with two other proteins - one is already used in routine practice.
Prof Jonathan Ball, a virus expert at Nottingham University, said: "The work addresses a really serious problem. Being able to identify a possible infection early on and then to be able to differentiate between a possible viral or bacterial cause, is important.
"This will allow informed clinical intervention and minimise the need for inappropriate use of antibiotics, for example with someone infected by a virus.
"It will be important to see how it performs in the long-term."