It began in March 1957. Police found a body dumped in a desolate sand pit in Ramsey, New Jersey. The remains belonged to Vickie Zielinski, a popular 15-year-old high school cheerleader whose skull had been crushed by a boulder, her clothes in disarray.

A neighbor, Edgar Smith, a machinist who lived in a nearby trailer park with his wife and daughter, was quickly identified as the likely killer. He was convicted of first-degree murder and sentenced to die in the electric chair.

A high school dropout who was reputed to have a 154 IQ, he became a savvy, self-taught jailhouse lawyer, filing appeal after appeal staving off his execution and adamantly denying his guilt.

So began the strange, riveting and horrifying odyssey of Smith, who became a cause celebre when influential conservative commentator William F. Buckley Jr. began campaigning for his release in the mid-1960s. Buckley profiled him sympathetically in Esquire magazine, helped establish a defense fund to retain top-notch lawyers and transformed Smith into a symbol of the heavy-handed justice of the state.

In a stunningly engineered plea bargain in 1971, the attorneys won Smith’s release. He wrote a book, “Getting Out,” made high-profile TV appearances and pulled down hefty fees for speeches before college audiences and legal groups.

After settling in California, his moment in the spotlight gradually dimmed. He became unemployed, went broke and began drinking heavily. He spent five years as a free man, then suddenly attacked again, a gruesome assault in which he kidnapped and stabbed a woman in San Diego.

At trial in 1977, he dropped a confessional bomb, admitting for the first time that he had murdered Zielinski after all, stunning the public and, most of all, Buckley.

In a Life magazine piece in January 1979, Buckley wrote, rather stiffly: “Other than that I and Smith’s other supporters were wrong, which is obvious — without its being obvious that we acted wrongly — what has come of it all? It is a pity that nothing that is generally useful has been written as a result of the Smith experience.”

Smith, 83, died March 20 in the prison system’s hospital in Vacaville, California. He had been suffering from diabetes and heart disease for several years, according to prison authorities. His death had not been previously reported.

Edgar Herbert Smith, known as Eddie, was born in Hasbrouck Heights, New Jersey, on Feb. 8, 1934. His parents divorced, and he was raised largely by his mother.

After dropping out of high school, he joined the Marines and worked as a flight crew member shuttling mail, troops and supplies in the Far East during the Korean War. Discharged in 1954, he worked as a bartender, truck driver and sewing machine salesman.

He landed a high-paying job as a machinist in 1955 and married Patricia Horton.

The pair lived in a northern New Jersey trailer court with their infant daughter, also named Patricia, when he had the ill-fated encounter with Zielinski.

According to prosecutors, Smith offered her a ride the night of March 4, 1957, drove her to the sand pit and beat her to death when she resisted his sexual advances.

At his trial, Smith acknowledged taking her to the sand pit but said he only slapped her when she told him his wife was cheating on him. He said she got out of his car and shortly thereafter was joined by another man, a mutual friend, who Smith suggested was her killer. Prosecutors scoffed at the idea.

In prison, he wrote a best-selling book, “Brief Against Death” (1968), asserting that prosecutors and police used coercive tactics — keeping him awake for more than 24 hours with little food — to extract incriminating statements.

The state courts did not agree. But when he appealed to the federal courts, he won a key ruling that tossed out the statements as illegally obtained and ordered a new trial. The decision greatly reduced the state’s ability to proceed again on a charge of first-degree murder.

While on death row, Smith became a voracious reader of books and magazines, including National Review. Buckley, the political goliath and editor of the conservative magazine, struck up a correspondence and became convinced of Smith’s innocence after reading his skillfully written appeals.

“Doesn’t it strain the bounds of credibility that an essentially phlegmatic young man, of nonviolent habits, would so far lose control of himself, in the space of a minute or two, as to murder under such circumstances a 15-year-old girl he hardly knew?” Buckley wrote in a 1965 Esquire magazine story.

He attacked the prosecutor’s case as “inherently implausible,” raised defense funds, hired the blue-chip Washington law firm run by legendary litigator Edward Bennett Williams and, after months of painstaking bargaining with prosecutors, helped win Smith’s freedom on a reduced charge of second-degree murder, to which he pleaded guilty in exchange for time served.

Within hours, the ex-con, who was also declared fully rehabilitated by the New Jersey courts, dramatically disavowed his guilty plea on Buckley’s nationally televised talk show “Firing Line.” He said the plea was a tactical ploy, pure “theater,” to get off death row and out of prison.

He scratched out a living in southern California. Then, in October 1976, the day after being turned down for yet another job, he forced 33-year-old Lefteriya Ozbun, a Greek immigrant seamstress, into his car as she was leaving her job at a garment factory in Chula Vista, California.

He taped her wrists and threatened to rob her. As he sped off down a highway, she loosened her hands, reached for the steering wheel, pressed on the brakes and was stabbed savagely.

She jumped from the stalled car and survived to testify against Smith after he was caught and subsequently convicted.

At trial, Smith confessed to the Zielinski murder, explaining that he had been moved during a visit to her gravesite while on the run in the Ozbun case.

“For the first time in my life, I recognized that the devil I had been looking at in the mirror for 43 years was me,” he told the court. “It was at that time I recognized that my life had reached a point at which I had a choice of doing two things: I could kill myself, or I could return to San Diego and face what I was.”

His marriages to Horton and later to Paige Hiemier ended in divorce. At a 1987 parole hearing in California, he claimed to have married a third time — to the mother of a former cellmate. A complete list of survivors could not be immediately confirmed.

After years of being denied parole, Smith wrote a letter to the Los Angeles Times portraying himself as a victim and blaming New Jersey prosecutors for what he did to Ozbun.

“Don’t ask me why I did it,” Smith wrote from prison in 1989. “Ask those self-righteous public servants why they gave me the opportunity to do it. Ask them why they did that to Lisa Ozbun. And ask them why they did that to me. Those are the questions they aren’t going to want to answer, but which need answering, which Lisa Ozbun and I need answered.”