A Lubbock County Sheriff’s Office SWAT commander was killed and four other deputies were wounded during an hourslong police standoff with a gunman Thursday in the West Texas city of Levelland. Authorities say the suspect was captured just before midnight.

Thursday's incident began when Lubbock SWAT team members responded around 2:15 p.m. to reports of shots fired, Fox News reports.

Three of the wounded officers were taken to a Lubbock hospital. Sgt. Josh Bartlett of the Lubbock County Sheriff's Office was taken to Covenant Health Levelland hospital and died of his wounds, according to a sheriff's office statement. Bartlett was the commander of the sheriff's tactical unit.

Levelland police Sgt. Shawn Wilson was in critical but stable condition in University Medical Center in Lubbock after surgery, Levelland Police Chief Albert Garcia said. The other three officers were treated for minor injuries and had been discharged from the hospital, he said.

Omar Soto-Chavira, 22, was injured when he was taken into custody around 11:30 p.m. at a home in Levelland, CBS reports. The suspect was being transported to a hospital in Lubbock for treatment, Garcia said. 

Law enforcement used robots to enter the home, then deployed gas which drew Soto-Chivara out of the residence, Lubbock County Sheriff Kelly Rowe said at the briefing.

Soto-Chavira bonded out of jail just four days ago after being accused of assaulting family members, KAMC-TV of Lubbock, reported.