The woman, who has not been identified, believed medics treating her were “actors or impostors”.
The judge explained his decision in a written ruling, after analysing the case at a hearing at the Court of Protection in early October, where lawyers representing doctors and the woman submitted evidence.
Mr Justice Keehan said he was satisfied the woman had breast cancer and that surgery was the right option.
Hospital chiefs had asked the judge to rule that the woman did not have the mental capacity to make treatment decisions and that surgery was in her best interests.
The woman was represented by staff from the office of the Official Solicitor, who help people who lack the mental capacity to make decisions.