UPPER MARLBORO, Md. (AP) — A police officer who mistakenly shot and killed an undercover detective has testified that he thought he was firing at a gunman who opened fire on a Maryland police station.

Taylor Krauss’s testimony on Monday marks his first public account of his shooting of his colleague Jacai Colson, who had worked with him in the same police unit, sitting at an adjoining desk.

Michael Ford is charged with murder in the March 2016 shooting death of the Prince George’s County police detective, who responded in plain clothes to the attack on the station. Ford fired up to 23 shots but didn’t hit anyone as his two brothers recorded him on their cellphones, in what his lawyer calls a failed attempt to provoke police into killing him.

Colson was black, like the suspects, and Krauss is white. Colson’s family says in a civil suit that he was carrying his badge and screaming, “Police, police!”

But The Washington Post reports Krauss said he never saw Colson hold up a badge or heard him identify himself as a police officer before shooting him once in the chest.

“Had I known it was a police officer, I never would have taken a shot,” Krauss said. “I believed he was a shooter.”

Prosecutors argue Ford is legally responsible for Colson’s death even though he didn’t fire the fatal shot.

Ford’s attorney, Antoini Jones, told jurors last week at the start of the trial that his client didn’t intend to harm anybody else.

One of the videos recorded by the brothers shows Ford screaming obscenities and shouting, “Do something!” in between shots.

A police detective testified in 2016 that Ford’s brothers agreed to record the shooting so the video could be sent to WorldstarHipHop.com, a website known for posting users’ violent videos. Prince George’s County State’s Attorney Angela Alsobrooks has said the cellphone videos were an attempt to gain fame.

Ford is charged with second-degree murder, attempted murder, assault and other offenses. His two younger brothers, Malik and Elijah, pleaded guilty to related charges and await their sentencings.

A grand jury declined to indict Krauss on any charges related to Colson’s shooting.

Colson, a four-year veteran of the department, drove up to the station, exited his vehicle and exchanged gunfire with Ford before the other officer shot him, police said.

Krauss, 37, said he had “tunnel vision” when he saw the man he thought was opening fire on the station, then became panicked and upset when he realized he had shot a fellow officer.

Krauss said he heard instructions through the police radio after Colson was shot: “Stop shooting toward the community center,” the voice said. “That’s a police officer.”

Colson’s parents sued Krauss and Prince George’s County over their son’s killing. Their wrongful death lawsuit says Krauss recklessly fired a rifle despite “visual obstructions.” Krauss shot twice through a wooden privacy fence before firing the shot that killed Colson, shooting from behind a wall at a distance of approximately 95 yards (85 meters), the family’s suit says.

Jones told jurors that evidence will show Colson didn’t match the gunman’s description, apart from their race, and was shot “because he was black.”

Follow @WJZ on Twitter and like WJZ-TV | CBS Baltimore on Facebook

(© Copyright 2018 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.)