Terrifying surveillance video captured the moment a wealthy Los Angeles homeowner opened fire on a pair of masked intruders who snuck up behind him as he walked up to his door.

The man is seen walking up to his Mid-City house about 7:30 p.m. Saturday, holding a drink in one hand and taking his keys out of his pocket with the other, footage posted by ABC 7 and Fox 11 Los Angeles shows.

One of the men, dressed in all black, sneaks up on him — but he quickly turns the tables by throwing his cup, whisking out a handgun and opening fire on the fleeing bandit.

“Out of nowhere I felt someone run up behind me, put something to my back, put a pistol to my back and somebody running up,” the man told ABC 7.

“I guess they decided to try to come at me and come in the house but I have a 5-month-old baby and a wife and a nanny in the house and that wasn’t going to happen,” he said.

“There was nothing in my house that was worth dying for. But I was willing to die for my family,” the dad added.

He told Fox 11 that he was wearing earbuds at the time — “which I never should have done.”

The man, who said he has a concealed carry permit, told Fox 11 that he was unsure if he struck either of the intruders, who had jumped over his front yard fence.

One of them appears to have gotten off a shot before escaping.

“If anybody else ever tries to come, they’re going to die for trying to come in this house,” the man told Fox 11. “There was one shot to get in — and that was it.”

“It’s a matter of time before these people get caught. I think they should just pick a new career before they do end up in jail,” he told ABC 7 after filing a report with the LAPD’s Olympic Division.

Police said they are investigating the shooting.

The disturbing incident comes as soft-on-crime LA District Attorney George Gascón — whose woke policies have been blamed for rising crime in the city and surrounding areas — has been assailed over his progressive directives to reform prosecutions.

Last month, LA County enacted a new rule that releases non-violent offenders back on the streets instead of holding them in jail until their arraignment.

Critics of the progressive policy said they were bracing for more of the smash-and-grab incidents that have plagued big-name stores and mom-and-pop shops alike.

Residents expressed concerns that this could cause an uptick in crime.

“What if someone comes in and tries to break into my house … but they didn’t harm me,” one named Silvia told local KTLA. “I’m freaking out because he’s in my home. That’s non-violent, right?”