WATERLOO, N.Y. (AP) — The gunman who fatally shot two people and wounded a third in an upstate New York village this week was recently released on bail twice after two separate arrests last month, the second for an alleged rape, authorities said Thursday.

State police Capt. Barry Chase said Emerson Tohafjian, 48, of Fayette, remained in custody at a hospital and faces charges in Tuesday's late-night shooting in Waterloo, in the Finger Lakes region in Seneca County.

Police said a taxi had just dropped the two women off at one of their apartments around 11:30 p.m. Tuesday when they were gunned down. Police have said the man was shot and killed at the same location, but they haven't released details on the relationship between the three victims.

One of the women survived being shot and called 911, Chase said. She was treated at a hospital and released, he said.

Chase said the victims' names will be released after autopsies being conducted by the medical examiner's office in Rochester are completed.

Troopers tracked down Tohafjian at a campground in neighboring Ontario County around 4:30 a.m. Wednesday, police said. A state police SWAT team and negotiators surrounded his small tent and Tohafjian surrendered three hours later, Chase said.

Tohafjian had cut his neck and a wrist before surrendering, police said.

"He's got an extensive criminal history," Chase said Thursday.

Seneca County District Attorney Barry Porsch said Tohafjian was arrested twice last month in two different local towns. The first occurred June 3 for misdemeanor charges, including assault. Porsch said the second occurred June 19, when he was charged with rape and unlawful imprisonment.

Tohafjian was released on bail after both arrests, the district attorney said. He was last released from jail on June 21, Porsch said. When Tohafjian failed to make a scheduled court appearance June 27, prosecutors requested a bench warrant be issued for his arrest, but that was denied by a judge, Porsch said.

Porsch said he couldn't confirm if either of the women was connected to the June cases because state law prohibits the names of sex crime victims from being disclosed.

Waterloo, a village of about 5,000 residents in the Finger Lakes region between Rochester and Syracuse, hasn't had a homicide in more than 20 years, according to Police Chief Jason Godley.