A very lucky police dog and very thankful corrections officer are back together patrolling the cell blocks of Rikers Island thanks to the help of a pacemaker.

Blaze, a 4-year-old black German shepherd, is expected to have a long career facing down violent inmates and restoring order during jail-yard riots thanks to a quick-thinking doctor who diagnosed him with a rare heart condition.

The young dog, which has been with the city corrections unit for three years, keeled over five months ago while on the job.

His partner, Correction Capt. Efrain Madera thought the dog was having a seizure, only he wasn’t shaking. Instead, Blaze was still with his eyes open. Although he got up and went back work, Madera’s four-legged friend collapsed two more times in the six weeks that followed the initial incident.

Concerned, Madera took the dog to the Animal Medical Center on East 62nd Street, which provides medical attention to all of New York's police dogs. Dr. Philip Fox, a board-certified cardiologist who’s worked at the AMC for 30 years, diagnosed Blaze as having a heart blockage, which was preventing its electrical current from penetrating the heart muscle.

“The dog was weak with a dangerously slow heart rate and it had just started to enter into the early stages of shock,” Fox said Wednesday. “He was in shock because there was a lack of blood supply that stemmed from heart beating too slowly.”

Blaze’s shock would have eventually led to death had a pacemaker not been implanted under his skin and wired into his heart, Fox told Foxnews.com.

“The pacemaker is programmed to discharge the electrical shock that travels through the wire and stimulates the heart muscle,” Fox said. “It makes the heart muscle contract and supplies the blood flow in the same way that it would for a person. And they’re neutral so the animal doesn’t sense that it’s under the skin.”

Pacemakers have been used in dogs since 1968, though it’s very rare that dogs have the need for one, said Fox.

“It’s quite unusual and this is one of the few young dogs I’ve ever seen with this condition,” he said. “I could be wrong, but I’ve never heard of a police dog needing one.”

Thanks to his pacemaker, Blaze should live out a normal life. And Blaze’s partner is excited to have his pal back on the job.

"He means everything to me. He's like my son," Madera told the New York Post this week.