Tests on 97 men, described in Science Translational Medicine, were able to tell whether tumours were already resistant to the drug abiraterone.
Doctors at the Institute of Cancer Research in London will now trial the test to see if it can extend lives.
Prostate Cancer UK said such a test would also avoid unnecessary side-effects for men.
Abiraterone is a potent drug able to shrink tumours, but only some men benefit.
Cancers can evolve resistance to drugs over time, so the team of scientists set about looking for evidence in the fragments of tumour DNA that float in the blood stream.
Abiraterone works by hitting the male hormone receptor on prostate cancer cells.
But the team discovered that mutations affecting the male hormone receptor stopped the drug from working.
The men were more than seven times more likely to respond to treatment if they did not have these mutations.
Dr Gerhardt Attard, from the Institute of Cancer Research, told the BBC News website: “We have identified a group that should not have abiraterone and another set who have great benefit.
“This is the first study in prostate cancer to predict which patients are going to respond, it’s very compelling data to suggest we could have a test.”
Only 17 men in the trial had tumours shrinking in response to the therapy.
Fifteen of them had normal male hormone receptor, and only two had the abiraterone-resistance mutation.
And those two, who seemingly responded, had only a short-lived effect and their cancer rapidly rebounded.
The researchers are now trailing the test in 600 men to see if those with abiraterone-resistant tumours would be better off being given chemotherapy straight away.
Full story on the BBC website.