On Oct. 5, 1976, a man in a ski mask burst into Jane Carson-Sandler’s bedroom in her suburban Sacramento, Calif., home.

The stunned mom was sitting in bed with her 3-year-old son. It was 6:30 a.m.

The intruder held a butcher knife to the 30-year-old mother’s chest, gagged them both and tied their wrists with shoelaces he’d brought with him.

“Shut up, or I’ll kill you,” he growled through clenched teeth.

Then he raped the terrified woman on her bed as her son sat on the floor beside them.

The attack was among the first carried out by one of the country’s most prolific serial killers and rapists — a monster whose reign of terror gripped California in the 1970s and ’80s and who eluded capture for more than four decades.

Until now.

A former cop was arrested Wednesday and identified as the Golden State Killer — the fiend responsible for at least 12 homicides, 51 rapes and 120 home burglaries and whose crimes were chronicled in the recent best-selling book “I’ll Be Gone in the Dark,’’ authorities said.

Ex-police officer Joseph James DeAngelo Jr., now 72, was busted on two counts of murder and arrested in connection with four more thanks to DNA evidence, officials said. They said they believe he is the maniac behind the other crimes and are still working on collecting evidence against him to bring more charges.

Authorities said they put the balding dad under surveillance for the past few days — and finally nailed him by matching DNA material recently discarded by the ex-cop to genetic remnants collected from crime scenes decades ago.

The suspected serial killer worked as a cop in the Exeter Police Department from 1973 to 1976 and then in Auburn from 1976 until 1979 — when he was fired for shoplifting a hammer and a can of dog repellent, authorities said.

They said they are now looking into whether he may have been on duty when he committed at least some of his heinous acts.

‘We found the needle in the hay stack — and it was right here in Sacramento’

“Very possibly he was committing the crimes while he was a police officer,’’ a Sacramento County Sheriff’s Department spokesman said at a press conference Wednesday.

At the very least, DeAngelo allegedly pulled off his spree right under their noses.

The suspect is a longtime resident of Sacramento and was arrested only after a renewed push into his crime spree — which included authorities fielding a steady stream of tips stemming from the release two months ago of the riveting book “Ill Be Gone.’’

The true-crime tome was penned by Michelle McNamara, the late wife of comedian Patton Oswalt.

McNamara dubbed the mysterious serial murderer the Golden State Killer — but he has also been known as the East Area Rapist, the Original Night Stalker and the Diamond Knot Killer.

“We all knew we were looking for a needle in a haystack,’’ said Sacramento County DA Anne Marie Schubert, who is credited with putting together the intrastate task force that finally cracked the case.

“But the needle was there . . . We found the needle in the hay stack — and it was right here in Sacramento,” said Schubert, adding that officials nailed him through “innovative techniques” involving “DNA technology.”

Carson-Sandler, victim of the 1976 attack, cheered the arrest.

“I just found out this morning,” she told The Island Packet newspaper Wednesday. “I’m overwhelmed with joy. I’ve been crying, sobbing.

“After 42 years — wow!”

Bruce Harrington, the brother of slain victim Keith Harrington said, “It is time for victims to begin to heal — it’s long over due.

“And for the . . . ladies brutally raped, sleep better tonight. He isn’t coming in the window; he’s in jail.”

The serial killer’s twisted spree began with rapes in east Sacramento County in the summer of 1976.

He often used the same approach when attacking the women — climbing into their homes through windows and blinding victims with a flashlight before tying them up with shoelaces he’d brought and raping them.

During the meticulously planned attacks, he usually spoke through gritted teeth to disguise his voice.

“F–k me like your old man,” he hissed at one woman.

As he brutalized another, he asked, “Isn’t this good?” — and held a knife to her throat until she said yes.

In another case, he said, “You’ll be silent forever, and I’ll be gone in the dark” — a threat that inspired McNamara’s book.

The murderer collected “trophies,” including victims’ wedding rings and bikini Polaroids, as keepsakes.

He also would sometimes call the women afterward to taunt them.

As years passed, the killer grew more bold.

He began attacking women while they were at home with men — and would sometimes stay for hours after the rape, rifling through their belongings and even cooking meals.

He would park just outside a police patrol perimeter, between two houses or on a vacant lot, to avoid being detected.

Authorities say his first murder was in February 1978, when he chased and gunned down Brian and Katie Maggiore, newlyweds who were walking their dog in the quiet city of Rancho Cordova.

Other victims were beaten to death with objects such as crowbars, wrenches and fireplace logs.

In the 1970s, the killer was reported to be a white man, about ­5-foot-10 with light hair and an athletic body. Investigators collected his DNA and searched for years without a match.

All told, he targeted victims — teens, med students and happy couples among them — in 10 counties over a 12-year span. The attacks ranged from Sacramento County to Orange County, 400 miles to the south, authorities said.

Decades after the case ran cold, McNamara began her own exhaustive investigation into the identity of the killer for her book. But she tragically died at age 46 before she could finish it.

In April 2016, she took a fatal mix of prescription drugs. She had reportedly been so obsessed with finishing the book — and fixated on its horrifying antagonist — that she suffered from insomnia, anxiety and weight gain. She began self-medicating with the prescription drugs and died of their abuse and a heart blockage, according to past reports.

“I’m obsessed [with the case]. It’s not healthy,’’ she wrote on her true-crime blog in 2011.

Oswalt, who shared her passion for the case, said after her death, “It’s so clear that the stress led her to make some bad choices in terms of the pharmaceuticals she was using,’’ according to The New York Times.

On Facebook, he added, “I can’t help feeling that somewhere, in her final pages, she left enough clues for someone to finish the job she couldn’t — to put California’s worst serial killer behind bars.”

In the week before DeAngelo’s arrest, “We started surveillance of him. We were able to get discarded DNA and confirm what we already knew — that we had our man,” a Sacramento sheriff’s spokesman said.

Orange County DA Tony Rackauckas crowed, “James DeAngelo has been called a lot of things by law enforcement.

“He’s been called the East Side Rapist; the Visalia Ransacker. The Original Night Stalker. The Golden State Killer.

“Today it’s our pleasure to call him defendant.

“It was a great thing to re-spark this investigation . . . It’s wonderful that it was eventually solved.”

On Wednesday, Oswalt took to Twitter to credit his late wife with helping to keep the case alive, thus helping to solve it..

“I hope I get to visit him,” he wrote of DeAngelo. “Not to gloat or gawk — to ask him the questions that [my wife] wanted answered.”

Oswalt then added, “I think you got him, Michelle.”