A man stabbed a doctor while being treated at a psychiatric ward at a Boston medical building Tuesday and was fatally shot by an off-duty security guard who saw the attack, police said.

The attack took place in the afternoon at 50 Staniford St., a high-rise building affiliated with Massachusetts General Hospital.

The female doctor, whose name was not released, was in stable condition. Police say the suspect died of the gunshot wounds. The security guard was off duty and just happened to be at the scene, according to Massachusetts General.

Police locked down the building, telling employees and patients that they could not immediately leave. Nearby streets were shut down.

Police Commissioner Ed Davis later said no one else was injured, and there was no further danger.

The attack took place at the Massachusetts General Hospital Bipolar Clinic & Research Program, in a building near the main hospital. The program provides clinical care, conducts research and educating the community about bipolar disorder, according to its Web site.

The building is in a largely commercial area. It contains businesses with treatment specialties and several medical groups associated with Massachusetts General.

Click here for more from MyFoxBoston.com.