A cosmetic-surgery firm that denied breast reduction surgery to three men with HIV violated the Americans with Disabilities Act (ADA) by failing to consider the medical facts regarding each patient before deciding whether surgery could be safely performed, a judge said Wednesday.

U.S. District Judge Analisa Torres issued the written opinion against Advanced Cosmetic Surgery of New York, which has offices in Manhattan and Long Island.

"It is Defendants' burden to demonstrate that the application of any criteria screening out individuals with HIV was 'necessary.' Defendants cannot meet their burden when they automatically reject potential patients without 'making [a] determination based on their medical necessity.' Defendants have therefor run afoul of the ADA," Judge Torres wrote in her ruling.

The U.S. government and a New York resident, Mark Milano, filed the lawsuit in 2015, contending the business had a blanket policy of refusing surgery to anyone with a history of HIV infection.

Lawyers for the company did not immediately return a message seeking comment Wednesday. But in court papers, lawyers for Springfield Medical Aesthetic, which operates the medical offices, said the issue was whether a licensed physician could be held liable for refusing to perform elective cosmetic surgery on HIV-positive patients based on the physician's judgment the patients' medications could interfere adversely with medications used in the surgery.

"This case is not about physician who holds discriminatory animus toward HIV+ patients," the lawyers wrote. "Importantly, this case is not about fear of infection by the physician or his staff when treating HIV+ patients."

The lawyers called it an instance of judicial first impression and noted the government did not cite any U.S. case in which a court had applied the ADA or federal or local law to overrule a physician's medical decision not to treat an HIV-positive patient.

"Very rarely would a person’s HIV status provide a valid medical reason not to perform a health service, and people living with HIV should know that and assert their rights in situations like this." Scott A. Schoettes, Lambda Legal HIV Project Director and Counsel

The judge acknowledged the issue had not been addressed before in the courts but said there was precedent in a Supreme Court case that found a teacher living with tuberculosis was unjustly fired (School Board of Nassau County, Florida v. Arline). In that case, the trial judge did not conduct an individualized inquiry into the health risks, if any, posed by the teacher's disease.

Torres wrote that the medical practice at Advanced Cosmetic Surgery violated federal law in HIV-related cases by failing to investigate whether drugs taken by the three men would threaten their health as a result of surgery. The judge also said the company violated New York City Human Rights Law.

"Defendants' blanket refusal without individualized inquiry is insufficient to pass muster under the ADA," the judge wrote.

Lawyer Ali Frick, representing Milano, said the court "elevated science and facts over fear and prejudice."

"Discrimination against people living with HIV remains a pervasive problem," the lawyer said. "A doctor cannot hide behind his medical degree to discriminate against patients."

Scott Schoettes, an attorney and HIV Project director at Lambda Legal, a national legal organization for the LGBTQ community and those living with HIV, echoed Frick.

“Sadly, this type of discrimination — even by doctors — is far too common," Schoettes said in a statement emailed to NBC News. "Twenty years ago, the U.S. Supreme Court decided (in Bragdon v. Abbott) that health providers cannot hide behind their personal ignorance regarding the facts about HIV to deny people services. Very rarely would a person’s HIV status provide a valid medical reason not to perform a health service, and people living with HIV should know that and assert their rights in situations like this.”

Milano said he had lived with HIV for 30 years but felt it "like a punch in the gut" when he was told by the doctor that he never performs procedures on people with HIV.

"It left me on the verge of tears," he said. "I had never experienced such blatant HIV discrimination in my life."

There will be a damages trial, and Milano could be entitled to a financial payment.

In court papers, lawyers for the government wrote that a doctor does not have "unfettered discretion to decide, without any supporting medical evidence, that he can turn away whatever patients he wishes."

FOLLOW NBC OUT ON TWITTER, FACEBOOK AND INSTAGRAM