TEWKSBURY, Mass. (AP) — The Massachusetts Appeals Court has ruled that a woman who was raped in a locked unit at Tewksbury State Hospital cannot sue the state for damages.

In a 3-2 decision Wednesday, the court found that part of a state law known as the Massachusetts Tort Claims Act protects the government and its employees when they are not the original cause of the injury.

Both the woman and the man who raped her were patients at the hospital. The woman became pregnant and suffered a miscarriage.

The Appeals Court upheld a ruling by a Superior Court judge.

Two judges dissented, finding that the state created the environment that allowed for the rape to take place. The hospital separated men and women for sleeping, but allowed shared access to the recreation room, where the woman was raped.