Newly released video shows the moment a police officer in Texas opened fire to try to stop a man stabbing a woman to death.

The incident happened in December 2017 as the Austin officer responded to a report of a stabbing at an apartment complex and came across 52-year-old Aubrey Garrett in the act of attacking the victim.

“This was a very rare moment when the officer actually came upon the offense as it was being committed and captured part of the stabbings on camera,” Travis County District Attorney Margaret Moore told FOX7.

GEORGIA SERGEANT WHO SERVED IN ARMY FOR 21 YEARS IS GUNNED DOWN WHILE INVESTIGATING ROBBERY

A witness told police at the time the stabbing went on for about 30 minutes before officers arrived.

In the video, the officer can be seen running and approaching the attacker as he tells him to "put the knife down, dude."

An Austin police officer is seen shooting at Aubrey Garrett after he continued to stab a woman in December 2017.

Garrett then says "no" and continues to stab the victim, forcing the officer to fire one shot at the suspect.

“The officer was ordering the defendant to stop and he didn't, and the officer shot once, managing to wound the defendant," Moore said. "He was shot low because he could see there were witnesses in windows behind the defendant and he didn't want to endanger them."

"This was a very rare moment when the officer actually came upon the offense as it was being committed and captured part of the stabbings on camera."

— Travis County District Attorney Margaret Moore

The woman, later identified Andrea Faye Lindsey, died afterward. Garrett pleaded guilty to killing Lindsey and was sentenced to 40 years in prison, according to FOX7.

'SUSPICIOUS' CLOWN NOT CREEPY AT ALL, COPS SAY; JUST A 'NICE' MAN CELEBRATING HIS BIRTHDAY

The December 2017 shooting was the first officer-involved shooting in the district where body camera video was available on the scene and showed the officer was within his right to use deadly force, according to Moore.

“I think it was very significant for us, because we had not realized, until that point, how clear and helpful the videotape was going to be,” she told FOX7.

CLICK HERE FOR THE FOX NEWS APP

The president of the Austin Police Association said the group backs the use of body cameras "100 percent."

"It's not only safer for the officers, it's safer for the community, and provides more transparency, but also provides better prosecution,” Ken Casaday said.

He added, however, that officer's accounts should also be considered because sometimes "angles can be a problem."