A Santa Barbara doctor some patients called "the candy man" because he so freely prescribed painkillers and other commonly abused narcotics pleaded guilty Thursday to federal drug charges.

Julio Diaz, 65, pleaded guilty to 11 counts of drug dealing, stemming from prescriptions written from his storefront office on Milpas Street. As part of the plea, the doctor acknowledged prescribing drugs to patients who had no legitimate medical need.

Diaz was taken into custody after the hearing in U.S. District Court in Santa Ana, said Assistant U.S. Atty. Ann Luotto Wolf. He is scheduled to be sentenced in June.

In an interview before his arrest, Diaz told The Times he was aware of only one fatal overdose within his practice. After being shown coroner's reports on his patients, he acknowledged multiple deaths and said he shared blame in some of them.

"I do feel responsible," Diaz said. "I was the one providing the medications and perhaps there were some hints there that I should have known they were going to overdose."

Looking back, he said, the overdoses "gave me a good lesson."

Among those who died: A 49-year-old father who overdosed on painkillers shortly after completing a 60-day drug rehab; a 35-year-old mother found dead in her bedroom by her young daughter, who was hosting a friend for a sleepover; an out-of-work county bus driver who was battling depression and overdosed on painkillers and other drugs.

Other doctors in the community and the family members of some of his patients had complained about Diaz to the state medical board for years before his arrest. A doctor at a local hospital determined that Diaz's patients were seen in the emergency room for drug intoxication on 410 occasions over two years, court records show.

In the Times interview, Diaz described himself as a caring family physician who gradually developed a pain practice to meet the needs of patients who had difficulty finding help elsewhere. That part of his practice, he said, was fraught with trouble, such as drug-seeking patients, office burglaries, pharmacists refusing to fill his prescriptions, complaints from patients' loved ones and the specter of investigation.

Diaz was not charged with any patient deaths. Wolf, the prosecutor, said filing such charges is complicated by various factors, including patients obtaining drugs from multiple doctors, mixing prescription drugs with street drugs, and having preexisting medical conditions that contribute to their demise.

In Diaz's case, she said, the drug dealing counts alone are likely to result in a "just and reasonable" sentence. He faces a statutory maximum of 200 years, though he is likely to receive far less time.

Wolf said it is likely some deaths will be brought up during an evidentiary hearing before sentencing.

Margaret Ann Pollock's husband got prescriptions from Diaz and died of an overdose in 2009.

"I'd love to see him get the max," Pollock said Thursday. "I just feel he was instrumental in my husband's death and the loss of my kid's father."