(Reuters) - A gunman opened fire inside a Pennsylvania psychiatric facility on Thursday, killing a woman and wounding a doctor who apparently shot back and critically wounded his attacker, authorities said.

The 23-year-old armed man walked into the psychiatric unit of the Sister Marie Lenahan Wellness Center, where police believe he was a patient, across the street from Mercy Fitzgerald Hospital in Darby, Pennsylvania, at about 2 p.m., Delaware County District Attorney Jack Whelan said.

He fired at a psychiatrist, who was grazed on the side of the head by a bullet, and fatally shot a female social worker, Whelan said.

Wheelan said authorities believe that the doctor, who was armed, fired back and struck the gunman several times in the torso.

The suspect was taken to the University of Pennsylvania Hospital in Philadelphia, where he was listed in critical condition and undergoing surgery, Whelan said. The doctor also was hospitalized.

Whelan said the man was known to have psychiatric issues. It was unclear if the shooter was a patient of the doctor involved in the incident.

"It's horrendous. Any time you have an incident like this it's certainly horrendous," Whelan told a news conference.

Darby is located about 7 miles (11 km) west of Philadelphia.

(Reporting by Daniel Kelley in New Jersey, Barbara Goldberg and Curtis Skinner in New York; Editing by Sandra Maler and Ellen Wulfhorst)