Sgt. Rod Lucas, a 20-year veteran who had been on the force since he was 26, was shot in an office Monday as he talked about backup weapons, the sheriff said.
"So far, we have absolutely no reason to believe this was [anything] more than a tragic accidental shooting," Sheriff Margaret Mims said.
Two other employees were in the room, but were not hit.
The detective and the others tried CPR and other attempts to save Lucas, but he died at a hospital.
"Rod Lucas was very well-respected. ... He truly was a leader in the best terms that I can describe," Mims said. "He was looked up to by those that worked with him. He was the sergeant that people wanted to work for."
The name of the detective, who has not been interviewed yet, was not released. He is a nine-year veteran of the department.
Lucas' wife told Mims, "Please pray for us," according to department spokesman Tony Botti.
The deputy is survived by four children between the ages of 12 and 28. He had one grandchild.
The shooting occurred in a sheriff's special investigations unit building away from department headquarters.
The sheriff said the department was giving the detective a little time.
"As you can imagine, he's extremely upset," Mims said at a news conference. "We're getting him the help that he needs."
Lucas is the 110th officer in the United States to die this year, according to the Officer Down Memorial Page.
"Anne and I extend our deepest sympathies to Sgt. Lucas' family, friends and colleagues as they mourn this tragic loss," Gov. Jerry Brown said. "We join all Californians in honoring his dedication and service to the people of Fresno."