The precision medicine is already used by the NHS for ovarian cancer and has been called a game-changer by cancer doctors.
A cancer conference heard how, in trials, it slowed tumour growth in men with advanced prostate cancer.
This could improve survival for some men, researchers hope.
Experts say it could be made available to patients in the next couple of years.
The drug, made by AstraZeneca, was fast-tracked to NHS ovarian cancer patients in England, paid for through the Cancer Drugs Fund, in July.
Olaparib, also called Lynparza, works by targeting and killing cancer cells with faulty genetic code, while sparing normal cells with healthy DNA.
It won’t work for everyone with prostate cancer, but it is effective for some men with the disease, say researchers.
Patients can be tested to see if they have the genetic errors that the drug can attack – faulty DNA repair genes including BRCA1 and BRCA2.
This precision approach means the patients most likely to benefit will be treated, sparing them potential side-effects from other drugs that may not work as well for them.
In the trial, doctors compared olaparib with two other commonly prescribed prostate drugs (hormone treatments called abiraterone and enzalutamide).
It appeared to delay cancer growth by months, which researchers say should hopefully mean men can survive for longer even when their disease is advanced. They will be monitoring patients to confirm this.
About prostate cancer
One in eight men will be diagnosed with prostate cancer in their lifetime. It mainly affects men over the age of 50 and the risk increases with age.
Not all of these tumours need immediate treatment. If the cancer is at an early stage and not causing symptoms, doctors may instead suggest careful monitoring.
Some cases are more aggressive and need treatment but can be cured if caught early enough.
Other cases may only be diagnosed at a late stage when the cancer has spread and cannot be cured.
All treatments, including olaparib, can have side-effects.
Doctors can talk advise patients about what might be the best treatment for them.
Prof Johann de Bono, from the Institute of Cancer Research, London, who co-led the drug trial, said: “It’s essential that we become smarter in the way we treat prostate cancer, so that every man gets the treatment that will be of greatest benefit for them.”
Dr Matthew Hobbs, from the charity Prostate Cancer UK, said: “This hugely exciting result represents a revolution in the treatment of prostate cancer. It finally brings prostate cancer medicine into the 21st Century by giving us, for the first time ever, a therapy that makes use of genetic testing of the tumour to work out which men will benefit.
“This kind of precision medicine approach is already used to treat other cancers, and we hope olaparib will become the first of many treatments for prostate cancer which are based on this sort of detailed understanding of an individual man’s tumour.”
Prof Nicholas James from Cancer Research UK said: “Tailoring cancer treatment according to a tumour’s specific genetic faults is a core part of care in breast, lung or skin cancers to name a few, and has helped us give patients the treatments that are most likely to work for them. But with prostate cancer, we’ve been treating everyone the same way.
“Matching patients to the most appropriate treatment for their tumour type could radically change the way we treat prostate cancer. In this case, olaparib only slowed the disease down for a few months in a subset of men, but the approach itself is full of possibilities. And if we get to a point where we can tailor treatments in prostate cancer from an early stage, we can give every patient the best chance of being successfully treated.”