Deputy David Faiivae’s supervisor warned him not to get so close to the stash of fentanyl just before the trainee patrolman with the San Diego County Sheriff’s Department collapsed, unable to breathe.

If not for the quick lifesaving actions of Faiivae’s veteran partner during the medical emergency in a San Marcos parking lot last month, the rookie mistake would have proven fatal.

“He nearly died,” sheriff’s Cpl. Scott Crane said in a public-service video released this week by the regional law enforcement agency.

When Faiivae passed out and stopped breathing due to contact with the ultra-toxic narcotic — either from breathing it in or getting it on his skin — Crane kept him alive with prompt infusions of naloxone, an anti-overdose medication marketed under the brand name Narcan.

The two lawmen found the fentanyl, a synthetic opioid 50 times more potent than heroin, in the back of an SUV on their first call of the day.

After they tested the powder and determined what it was, Crane saw that Faiivae had ventured perilously near to the rear of the vehicle while processing the crime scene.

“I was, like, ‘Hey, dude, too close — you can’t get that close to it,'” Crane says in the video. “A couple seconds later, he took some steps back, and he collapsed.”

Video footage captured by Crane’s uniform-worn camera shows Faiivae lying on his back, staring blankly at the sky.

“I ran over, and I grabbed him, and he was O.D.’ing,” Crane said. “And I went to my trunk, grabbed the Narcan, came down to him, grabbed him again, and I gave him one nasal spray in one nostril … (and) another nasal spray in the other one.”

In the department video, Faiivae describes what he could recall about his near-death experience.

“I remember just not feeling right, and I (fell) back,” he said. “And I just — I don’t remember anything after that. … My lungs just locked up. … I was trying to gasp for breath, but I couldn’t breathe at all.”

After administering the naloxone, Crane asked his stricken partner to talk to him. As the antidote began to take effect, Faiivae whispered, “I’m sorry.”

“No, no, don’t be sorry,” Crane replied. “You’re OK. Don’t be Sorry. There’s nothing to be sorry about. I got you, OK? I’m not going to let you die.”

Though Faiivae had begun to come around, after paramedics arrived and put him onto a gurney for a trip to the emergency room, his “eyes rolled back in his head, and he started to O.D. again,” his supervisor said. “And he was O.D.’ing the whole way to the hospital.”

The young deputy only survived due to the Sheriff’s Department’s training and equipment in dealing with the lethal street drug that poisoned him, the corporal said.

“It’s an invisible killer,” Crane said. “He would have died in that parking lot if he was alone.”

Noting that deaths due to the drug in California increased nearly 46% over the last year, San Diego County Sheriff Bill Gore called it “one of the greatest threats we currently face.”

“Fentanyl overdoses are on the rise throughout our county,” Gore says in the department video. “Every day, deputies recover fentanyl in our communities. And the county jails are not immune either to the dangers of this drug. Every week, sheriff’s deputies intercept fentanyl entering our facilities.”

Detention deputies and medical staffers “are saving dozens of lives every month” by intervening in overdoses caused by fentanyl smuggled into local jails, according to Gore.

“Being exposed to just a few small grains of fentanyl could have deadly consequences,” the sheriff said. “The dangers of fentanyl are real, and this drug is killing our communities.”