A judge didn’t buy a hospital’s argument that it can’t be sued over a mix-up that ended in a woman taking a brain-dead stranger she was led to believe was her brother off life support — because neither she nor her actual brother were patients at the time.

Shirell Powell, 48, claimed St. Barnabas Hospital told her that her brother, Frederick Williams, had been admitted there in July 2018 after he had apparently overdosed, according to her January lawsuit.

The Crown Heights woman then devotedly sat by her brain-dead “brother’s” hospital bed for nine days and eventually made the tough decision to take him off life support, according to the suit.

But she would later discover the man was actually a look-alike who was around the same age and had a similar name, Freddy Clarence Williams, the suit said.

In February, a lawyer for the hospital argued it could only be held responsible for inflicting emotional damage on patients and since neither Powell nor her actual brother were patients at the time of the incident the lawsuit should be tossed.

Powell’s brother was in the hospital’s system because he had once been a patient there.

But Bronx Supreme Court Justice Howard Sherman rejected that argument Wednesday and said the suit can go forward.

“The hospital contacted the plaintiff (thus assuming a duty) and provided her with a false report of impending death (thus causing emotional distress). The act of contacting the plaintiff gave rise to the duty to provide accurate information as to the former patient,” Sherman’s order reads.

The judge said Powell can’t sue for Freddy Clarence William’s death, “But she may potentially recover for the distress that allegedly resulted from the consequences of the false identification of her brother as the unconscious patient, up to and including authorizing that life support be withdrawn from a person with whom she had no familial connection.”

Powell’s lawyer, Alexander Dudelson, told The Post, “I am happy with the decision and look forward to pushing this case forward. Now we can finally discover what in fact happened at the hospital.”

A lawyer for the hospital did not immediately return a request for comment.