SAN ANTONIO — ISIS leader Abu Bakr al-Baghdadi spent the final moments of his life running from one of the US Military’s greatest weapons: a vicious Belgian Malinois named Conan.

But dogs like Conan are not born heroes — they have to be finely honed from everyday puppies into fearless four-legged warriors.

And it is no walk in the park.

It all starts at the 341st Training Squadron on the Lackland Air Force Base in San Antonio, Texas, where the military’s K-9s have been schooled since the 1960s to take on America’s enemies.

“We treat these dogs like combat athletes. They are a huge mission force multiplier for us,” Major Matthew Kowalski, the commander of the squadron, told The Post during a recent visit to see first-hand what it takes to train a pooch like Conan.

“If we were able to find something that could do their job, a piece of equipment, the government would wholeheartedly most likely buy as many of those pieces of equipment as we could but we haven’t found anything since and probably never will.”

—

The squadron’s “Guardians of the Night” program prepares the dogs to do everything from detecting deadly explosives to taking down enemies of the state like al-Baghdadi — who ultimately blew himself up rather than face Conan’s snarling wrath as the animal cornered him inside a dead-end tunnel in Syria last month.

And that training starts as soon as the pups are born.

To prepare for war zones in any branch of the military, the animals need to feel comfortable in any environment, whether it’s an Army tank rumbling past the Syrian border or aboard a Naval ship docked off the coast of Africa.

“We want a dog who can be woken up at two in the morning, stuck in a running helicopter, flown somewhere for a couple of hours and be put down with a whole bunch of operators with lights flashing and shining and stuff like that and the dogs can do their job,” says Dr. Stewart Hilliard, a civilian animal behaviorist in charge of Lackland’s whelping kennel and breeding program.

Hilliard starts preparing puppies born on base for chaotic environments during their first six to eight weeks using ordinary activities like play and meal times.

To demonstrate during The Post’s visit, Hilliard brings out a 7-week-old puppy named FFleenor — a nom du guerre in honor of US Air Force veteran General Kenneth Fleenor, but with an extra letter Lackland uses to denote dogs born at the facility — and serves him a meal.

Puppy development specialist Kim Davis places a food bowl inside a plastic bin filled with squeaky, empty water bottles among an obstacle course of noisy distractions.

With bottles crunching under his feet, FFleenor chows down while Davis throws more bottles on top of the bowl, moves the bin up and down and shifts it across a clamorous metal gate.

Meanwhile, fellow puppy specialist Solange Lewalski creates a cacophony using chew toys, garbage bags, metal cups and a dusty plastic slide.

“We’re kind of desensitizing them with different sounds, different textures, different stuff going on while they’re eating so it’s not going to be a huge deal when they get out there and there’s a different environment,” Davis says.

Hilliard and his team also use fluffy chew toys and a rolled up towel attached to a wand to train the dogs to be interested in biting — a necessary tool they’ll need in the future when asked to take down enemies of the state in precarious war zones.

By the time the dogs are 7 months, Hilliard can tell which are going to be workers, and which are going to be pets, by assessing things like their “boldness,” capacity for aggression and how well they stand up to a human when challenged.

If the puppies hit the right marks, at around a year old they enter Lackland’s formal training pipeline.

—

The program is divided into two blocks: 65 days of detection training, or learning how to sniff for explosives and narcotics, and 55 days of patrol work — basically, how to chase down bad guys.

The detection training is like an exciting “game of chess” for the four-legged trainees, Captain Tate Grogan, the squadron’s director of operations, explains.

“It’s all mental… they’ll introduce the scents in an empty room with a piece of furniture in it and they’ll walk the dog around the room and when the dog shows interest… they’ll reward that dog,” Grogan says.

For most of the German Shepards, Beligan Malinois and Dutch Shepherds that make their way through the training school, play is their preferred treat — not food.

“For the dog, the missions are the same, it’s all a big game. I do my job and I get my reward. It’s as easy as that,” Kowalski says.

The mix of work and play is on full display as the dogs are put through their paces inside a sprawling parking lot filled with beater cars at Lackland.

Oscar Clayton, a retired K-9 handler who served in the Vietnam War, tests K-9 Senna’s ability to find different explosives — including TNT, potassium chloride and ammonia dynamite — hidden away in the vehicles.

Once Senna finds the explosive, its handler takes out a bright colored “Kong” — a plastic chew toy attached to a rope — and lets the future warrior gleefully attack it to reinforce the good behavior.

“If [the dog] can search 25 vehicles in the 100 plus degree on the asphalt here at Lackland then [they] can do that job in Iraq in the sweltering 120 degree heat in the sand,” Kowalski says.

Next up is patrol training, which takes place at a concrete obstacle course in a grassy field called “the pit” that’s outfitted with stairs, small tunnels and elevated windows.

Here, K-9 JJerbyll is being trained to chase after a suspect and detain them.

As a trainer posing as a “decoy” runs away from JJerbyll, her handler releases the dog — sending her bounding towards the decoy.

Dashing at between 20 and 30 miles-per-hour, it doesn’t take long for JJerbyll to catch up and soon she is five feet in the air, sinking her teeth into the decoy’s arm.

Just like the Army commando raid that led to al-Baghdadi’s capture, dogs in the field are often used to chase down suspects and hold on to them so “the human can then catch up,” explains Lt. Kayshel Trudell.

A few moments later, the handler runs the drill again. But this time, with JJerbyll pounding towards the decoy, the handler yells a command and the dog comes to a screeching halt — demonstrating the all-important skill of obedience.

“With a firearm you can shoot a bullet. Once it’s gone, you can’t stop it. This fur missile you can fire and if [the suspect] decides to give up or change their mind because they don’t want to get bit, then the handler can stop the dog and the dog won’t bite,” Grogan says.

But K-9s also need to back up their handler and pay attention to when they need to be protected.

In another drill, a handler tells JJerbyll to stay put while the decoy “suspect” is being searched. Suddenly, the suspect makes a move to attack the handler while his back is turned.

JJerbyll quickly lunges and strikes the decoy.

“The dog feeds off the handler and they also feed off the bad guy,” Grogan explains.

“The dogs are force multipliers in the sense that they’ve got unique skills that humans don’t and they multiply our capabilities.”

Still, the dogs are meant to be a “less than lethal force” and most often work as a “psychological deterrence,” says Sgt. Milo Bunts, one of the dog trainers.

“I’ve showed up on scene to something and the suspect was not being cooperative but as soon as the dog showed up and started barking, ‘ok ok I’ll do what you want me to do I give up,’” Grogan adds.

He recalled one time on a base in South Korea where a suspect was hiding in the woods.

“We didn’t have a dog so we barked as if it was a real dog,” Grogan said with a chuckle.

“The suspect came out.”

—

While Kowalski and other top officers couldn’t confirm if Conan had been trained at Lackland specifically, they did say nearly all of the dogs used by the Department of Defense are trained at the facility and there could be “multiple Conans” in the “inventory.”

All of the dogs make great sacrifices and play an integral role in the military – and have done as far back as World War II.

Kowalski recounted one moment from his time as a young lieutenant in charge of external security at Camp Bucca in southern Iraq back in 2007.

A K-9 at the base was performing a routine inspection on a semi-trailer packed with food and equipment that had just rolled up to the front gate when the dog discovered an improvised explosive device on the truck.

“Without that team there that semi-trailer would’ve come right on to base,” Kowalski said.

“That dog team saved everybody’s life that day.”

Whenever Kowalski sees a new working dog and handler heading off for deployment, he always thinks back to that moment.

“Could this be the next team that saves a lot of lives somewhere? And that kind of work is why we have such a high standard here at the 341st,” Kowalski said.

“We’re so proud to be part of this enterprise. Every time we see a dog as part of a raid or part of an operation… the unit and 341st members are so proud knowing that we probably had a hand in that good work.”