The shooting occurred just before 2 p.m. at the Park Sierra Apartments at 6450 Dougherty Road, Alameda County Sheriff's Sgt. J.D. Nelson said.
Nelson said several officers went there to search an apartment belonging to a suspect in a series of recent robberies on BART.
The two officers entered the apparently empty apartment and one officer accidentally fired a shot that wounded the other officer, Nelson said.
The wounded officer was taken to Eden Medical Center in Castro Valley, where he succumbed to his injuries, Nelson said.
Nelson said he assumes that the officers had their guns drawn as they entered the apartment but that the details of how or why the officer's gun went off remain unclear.
The suspect was not at home at the time of the shooting. Dublin police are investigating the shooting. The city of Dublin contracts with the sheriff's office for police services.
The BART officer that was shot has been identified as Sgt. Tom Smith, 42, who leaves behind a wife and 6-year-old child. He was the head of BART investigations and a training officer.
BART Police Chief Kenton Rainey and General Manager Grace Crunican said in a statement, "The entire BART organization is deeply saddened by this tragic event and we ask the public to keep the officer's family in its thoughts and prayers."
Rainey said that he and Crunican visited with the officer's family after the shooting to offer condolences and support.
The shooting marks the first death of a BART police officer in the agency's history.
Updated statement from BART Police Chief Kenton Rainey:
"Today's tragedy was the first death of an officer in the line of duty in the history of the BART Police Department. While performing a probation search, one BART police officer accidentally shot another officer who later died from the injury. The officers were following up on a crime committed on BART property. The Dublin Police Department (which contracts with the Alameda County Sheriff's Department) has taken over the investigation and no further details are available at this time."
ABC7 News contributed to this story.