BOSTON (Reuters) - A police officer, badly wounded in a gunfight with the Boston Marathon bomber four days after the deadly attack, was likely hit by a bullet fired by a fellow officer attempting to shoot the fleeing suspect, a Massachusetts prosecutor said on Tuesday.

Massachusetts Bay Transportation Authority police officer Dic Donohue nearly bled to death from a wound received during a gunfight with bomber Dzhokhar Tsarnaev in Watertown, Massachusetts, early on April 19, 2013, four days after the bombing that killed three people and injured 264.

"It is highly likely that the gun was fired by one of the individuals attempting to stop the armed Dzhokhar Tsarnaev, who was fleeing," Middlesex Country District Attorney Marian Ryan told reporters on Tuesday. "It is likely that it came from the gun of one of the officers who was trying to stop Dzhokhar Tsarnaev."

Donohue was wounded when Tsarnaev, now 21, attempted to flee the gunfight in a stolen car, inadvertently driving over his 26-year-old brother Tamerlan. The brothers had hurled improvised bombs and fired a handgun at police during the gunfight, which broke out hours after the pair shot dead a Massachusetts Institute of Technology police officer.

The younger Tsarnaev was sentenced to death by lethal injection for his role in the attack. Tamerlan died of injuries sustained during the gunfight.

Officials had not previously said whether Donohue was wounded by friendly fire, though accounts of the gunfight in local media and at Tsarnaev's trial suggested that the Tsarnaevs had ceased firing by the time Donohue was hit.

Donohue, who has since returned to duty, said he remained grateful for the medical assistance her received from fellow first responders.

"It does not take away from the heroic actions of those officers who ultimately prevented further acts of terror on the citizens of the United States," he said on Tuesday.

(Reporting by Scott Malone; Editing by Richard Chang and Eric Walsh)