ORANGE — State police troopers fatally shot a man who confronted them with a gun during a drug raid at 18 Mechanic St. shortly after 5 a.m. Wednesday, according to an agency spokesman.

A second firearm was found in the room where the 23-year-old man challenged troopers, according to police, who have yet to release the suspect's identity. The man lived at the Mechanic Street apartment, police said.

A 25-year-old woman, one of the targets of the investigation, was also in the apartment at the time of the raid. She was hospitalized with an eye injury and later released, police said. No information about possible charges have been released.

"The Massachusetts State Police Special Tactical Operations (STOP) Team made entry into a second-floor apartment at 18 Mechanic St. in Orange. The STOP Team was executing a search warrant in support of a narcotics investigation conducted by the State Police Detective Unit for Hampshire and Franklin Counties," state police spokesman David Procopio said in a statement.

As troopers raided the apartment, the man confronted them with a gun, prompting one or more troopers to open fire on the suspect, Procopio said. The suspect received medical aid at the scene before being taken to a local hospital, where he was pronounced dead, he said.

The investigation is being conducted by state police and troopers assigned to Northwestern District Attorney David E. Sullivan's office.

"The district attorney will ultimately review the use of deadly force by police to determine if it was justified under the law," Procopio said.

The police search warrant involved an investigation into the alleged sales painkillers, including oxycodone and Percocet.

Intelligence gathered before the raid indicated "the male suspect had access to, and may use, firearms," said police, who declined to provide additional details.

Authorities said the Northwestern Anti-Crime Task Force recovered five shotguns, heroin and alleged drug-packaging materials during a May 3 raid at 8 Mechanic St., Apt. 2. It was unclear in which apartment Wednesday's shooting occurred.

Kenneth Dennis, 46, a resident of the apartment, was arrested in the raid, according to records from Sullivan's office. At the time, the district attorney said the charges would include single counts of heroin distribution, heroin possession with intent to distribute and possession of a firearm during commission of a felony, and five counts of possession of a shotgun without a firearms identification card as a level three armed career criminal.