A Harlem doc who got caught writing phony prescriptions for more than 27,000 Oxycontin pills contends that an alternate personality named “Nala” was actually behind the scam.

A lawyer for Dr. Diana Williamson — who’s been acclaimed for her work with drug addicts — said in court this morning that she suffers from multiple-personality disorder stemming from childhood sex abuse by a perverted priest.

“I am keenly aware that Nala, while in Dr. Williamson’s body, committed some very serious crimes,” defense lawyer Jonathan Marks said, calling it a “mitigating factor” in the case.

But Manhattan federal Chief Judge Loretta Preska appeared dubious of Williamson’s “Sybil” defense, noting that no one has corroborated her self-described symptoms.

“It doesn’t seem to have impaired her ability to function as a medical professional,” Preska said.

Williamson, who was accompanied to court by about 15 supporters, didn’t speak in court, and declined to comment afterward.

She was supposed to be sentenced today for conspiring to distribute drugs and defraud the Medicaid program out of more than $300,000.

Under federal guidelines, Williamson, 56, faces up to 14 years in the slammer for the scheme, which used about 30 HIV patients at the Citicare clinic in Harlem as “straw buyers” of the pills, which were then passed off to a drug dealer and re-sold on the black market.

But Preska put off imposing punishment after Marks said Williamson’s severe asthma and anaphylaxis — which sent her to the emergency room six times in the past year — meant that any incarceration would amount to a “death sentence.”

Prosecutor Justin Anderson said federal prison officials would respond to those claims within the next two weeks.