The Maricopa County Sheriff's Office has released an edited body-camera video that shows a brief shootout between a man after a crash and a deputy in the northwest Valley on June 23.

Investigators say 22-year-old Michael Gerhart was speeding in his Toyota Rav4 on Grand Avenue/U.S. 60, lost control, and crashed, where he ended up on the median just south of Loop 303 around 6:30 p.m. The body-cam video shows the deputy getting out of his patrol truck with his gun drawn. "Do not move! I have a gun," the deputy is heard saying on the video.

Gerhart stays in his SUV, and it sounds like he shouts, "Stop!" a few times. The deputy then calls for Gerhart to put his hands up. About one minute into the video, Gerhart shoots at the deputy, and the deputy returns fire, shooting at Gerhart three times, AZ Family reports.

Gerhart fired his gun again. The deputy then takes cover behind his pickup truck and radios the dispatcher for help. The deputy was not hurt. Gerhart died at the scene.

An autopsy revealed Gerhart died of a self-inflicted gunshot wound, officials say.

Sheriff Paul Penzone said in a statement: “The deputy’s discipline, experience, and incredible instincts are the reason he was able to go home safe to his family and continue to protect our community members. I am thankful our deputy is alive and uninjured during these challenging times for law enforcement and the continued threat and danger in the course of our duties. I am also appreciative for the multijurisdictional commitment from other law enforcement agencies that assisted MCSO during this incident including Surprise PD and DPS.”