(CNN) -- A Denver-area police officer was fatally shot by a colleague who mistook him for an armed assailant early Friday, authorities said.
James Davies, a 35-year-old police officer in Lakewood, Colorado, was shot outside a house that he and fellow Lakewood officers -- including the firing officer -- were checking after hearing shots fired there, police spokesman Steve Davis said.
The firing officer, whom police haven't identified, thought Davies was an armed threat in the dark of night, the spokesman said.
"This has affected our entire department very, very deeply," Davis told reporters Friday afternoon. "I don't think it could have a more tragic set of circumstances."
The incident started when an officer, searching for the source of gunfire that had been heard in the area, saw someone firing a gun on the porch of the home in Lakewood, Davis said.
A number of officers, including Davies, arrived at the home and took three people into custody in connection with the gunfire. Preparing to enter the home a second time to search it for anyone else, officers surrounded the building, with Davies standing in the backyard, Davis said.
In a neighboring yard, on the other side of a fence, an officer saw Davies with a gun and didn't know he was a police officer, the spokesman said.
"It's my understanding that the firing officer could see either a silhouette or enough lighting to see someone with a gun, and mistook him for an armed suspect," Davis said. "Apparently there were some commands given, but quite frankly everyone seems to think Officer Davies thought that the other officer was in contact with someone else, and was giving commands to that person."
Davies, in full police uniform, would have had little reason to believe that the shouting officer was commanding him, Davis said.
The second officer shot Davies, who died at the scene, the spokesman said.
Davies, who had been with the department for more than six years, had a wife and two children. The department's chief spent part of Friday consoling Davies' family.
"You can imagine the anguish that the other officer is going through right now," Davis said. "We feel like we have two victims in the department, to be quite frank. That officer is really having a difficult time with what happened last night."
The incident will be investigated by a team of detectives from several agencies in Jefferson County, and a district attorney would decide whether to charge the firing officer after getting the investigators' report, Davis said.
Police didn't say what prompted the gunfire that attracted the officers to the home. The three people who had been detained hadn't been arrested as of Friday afternoon, Davis said. He said he didn't know whether they would be charged.
CNN's Jason Hanna, Bernadette Brown and Carma Hassan contributed to this report.
™ & © 2012 Cable News Network, Inc., a Time Warner Company. All rights reserved.