Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A Texas jailer who suddenly stopped breathing is now alive and well — thanks to a group of inmates who busted out of a holding cell to save him.

The inmates were in the basement of the Weatherford District Courts Building on June 23 awaiting court appearances when the guard sitting outside their pen slumped onto the floor, Capt. Mark Arnett with the Parker County Sheriff's Office told NBC News.

"He was just talking to them, and he just kind of collapsed," Arnett said Saturday. "As soon as the jailer went down, they started to yell."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

When that didn't attract the attention of anyone upstairs, the group of eight or so inmates, all of whom were shackled, broke out of their holding cell.

"They grabbed his radio and tried to radio for help," Arnett said.

Deputies upstairs heard the commotion. They came down and called for emergency personnel, who performed CPR on the jailer and used a defibrillator to shock his heart.

"He stopped breathing. They couldn't find a pulse on him," Arnett said.

The entire incident was captured on surveillance video.

Inmates in Texas broke out of a holding cell to save a deputy who stopped breathing on June 23. Parker County Sheriff's OFfice

The jailer, who doesn't want to be identified, is healthy now and is returning to work on Monday, Arnett said. The precise medical condition he suffered hasn't been disclosed.

One of the inmates, Nick Kelton, said he feared he would get in trouble for breaking out.

“We were worried they’re going to come with guns drawn on us," Kelton, who referred to himself as a meth addict often landing in jail, told ABC affiliate WFAA, which first reported the story.

The holding cell only has a "pretty flimsy lock gate" on it, unlike the reinforced doors of jail cells, Arnett said.

"All the inmates, they're in handcuffs," he said. "We just stick them in there so they're not wandering around and so they don't grab somebody's gun."

Arnett, however, praised the altruistic inmates for their quick action.

"They definitely saved his life. There's no doubt about that," he said.