SACRAMENTO — It was a rash of sadistic rapes and murders that spread terror throughout California, long before the term was commonly used. The scores of attacks in the 1970s and 1980s went unsolved for more than three decades. But on Wednesday, law enforcement officials said they had finally arrested the notorious Golden State Killer in a tidy suburb of Sacramento.

Joseph James DeAngelo, 72, who was taken into custody outside his home on Tuesday and charged with six counts of murder, had been living undisturbed a half-hour drive from where the 12-year rampage began. He was described as a former police officer, and his time in uniform partly overlapped with many of the crimes he is accused of committing.

The case was cracked in the past week, Sheriff Scott Jones of Sacramento County said on Wednesday, when investigators identified Mr. DeAngelo and were able to match his DNA with the murders of Lyman and Charlene Smith in Ventura County in 1980.

“We found the needle in the haystack and it was right here in Sacramento,” said Anne Marie Schubert, the Sacramento district attorney, who helped organize a task force two years ago that included investigators from across the state as well as the F.B.I. A DNA database showed links to other murders in Southern California, the authorities said Wednesday.