Attorney Charles N. Shaffer, right, with John W. Dean III, former White House counsel, in 1973. (UPI)

Charles N. Shaffer, the attorney for onetime White House counsel John W. Dean III, whose explosive testimony before a Senate committee directly linked President Richard M. Nixon to the Watergate break-in and coverup, leading to the president’s resignation in 1974, died March 15 at his home in Woodbine, Md. He was 82.

He had complications from heart surgery, said his stepdaughter, Melissa C. Randolph.

Before his high-profile representation of Dean, Mr. Shaffer (pronounced SHAFF-er) served as a Justice Department lawyer during the Kennedy and Johnson administrations and as a staff member of the Warren Commission, which investigated the assassination of President John F. Kennedy.

He also assisted in the 1964 prosecution of Teamsters boss Jimmy Hoffa for jury-tampering, which led to the only conviction of the embattled union leader.

Mr. Shaffer was best known, however, for his work with Dean, the White House insider turned whistleblower. Dean was still Nixon’s White House counsel when, in March 1973, he asked Mr. Shaffer to represent him.

Dean said he had spoken with Nixon on many occasions about the aftermath of the Watergate break-in, which occurred June 17, 1972, at Democratic national headquarters in the Watergate office complex in Washington. Asked to investigate for the White House, Dean warned Nixon in an Oval Office meeting that the growing scandal was “a cancer . . . close to the presidency.”

As details of the break-in and coverup became more widely known, three of Nixon’s top aides — H.R. Haldeman, John Ehrlichman and Richard Kleindienst, the attorney general — resigned on April 30, 1973. Dean was fired the same day.

By then, Mr. Shaffer and another lawyer, Robert C. McCandless, had been advising Dean for weeks and had learned of the president’s involvement in a possible criminal conspiracy. Dean was implicated as well, and in October 1973 he pleaded guilty to conspiracy to obstruct justice.

According to Dean’s 1976 memoir, “Blind Ambition,” and other sources, Mr. Shaffer advised Dean to be forthcoming with investigators about what he had learned of Nixon’s actions. During five days of testimony in June 1973 before the Senate select committee on Watergate, Dean said he had discussed the coverup in detail in several meetings with Nixon, some of which had been recorded.

Dean said that the president had been willing to pay hush money to various Watergate defendants and that the activities of some operatives had been “cleared” with Nixon by his chief of staff, Haldeman. Dean testified that orders to burglarize the office of the psychiatrist of Daniel Ellsberg, who released the Pentagon Papers to news organizations in 1971, came “right out of the Oval Office.”

The shocking testimony shook the Nixon presidency to its core, and Congress began impeachment proceedings. Nixon resigned on Aug. 9, 1974.

A week before Nixon’s resignation, U.S. District Judge John J. Sirica sentenced Dean to one to four years in federal prison for his role in the Watergate conspiracy. During the sentencing hearing, Mr. Shaffer pleaded for a postponement, saying the pending release of White House tapes would show Dean in a better light.

“Dean is the one who broke the case for the government,” Mr. Shaffer said in court.

In January 1975, without warning, Sirica ordered that Dean be released from prison after only four months.

“I think it’s a good step toward ultimate justice,” Mr. Shaffer said at the time. “I’m very pleased for my client.”

Charles Norman Shaffer Jr. was born June 8, 1932, in New York City. His father was a lawyer. He received bachelor’s and law degrees from Fordham University in the 1950s.

After serving as an assistant U.S. attorney in New York, Mr. Shaffer came to Washington in 1962 as a lawyer in the Justice Department’s criminal and tax divisions.

He was a staff member of the Warren Commission, the panel investigating Kennedy’s assassination, in 1964. The commission’s report, which stated that Lee Harvey Oswald was the lone gunman responsible for the shooting in Dallas on Nov. 22, 1963, has been the subject of controversy for 50 years.

In a 2014 interview with author and investigative reporter Philip Shenon, published in The Washington Post, Mr. Shaffer said he suspected that Oswald may have had connections to organized-crime figures before the assassination.

“The Warren Report was an honest report, based on what we knew at the time,” he said. “But nothing should have been written in stone. There were later developments that convinced me that maybe we missed something.”

Other members of the Warren Commission staff called Mr. Shaffer’s comments “nonsense.”

Mr. Shaffer lived in Potomac, Md., before moving to Woodbine and continued to practice law until his death. He was widely known in equestrian circles and participated in fox hunts with the Potomac Hunt Club, Goshen Hounds and New Market-Middletown Valley Hounds, all in Maryland.

His marriage to Diana Dolan ended in divorce. Survivors include his companion of 25 years, Christine M. Pulford of Woodbine, and her daughter, Melissa C. Randolph of Rockville, Md.; four children from his marriage, Monica Karo of Los Angeles, Leslie M. Shaffer of Fort Lauderdale, Fla., Norman Shaffer of Seattle and Camille Farnan of Franklin, Mass.; a sister; and nine grandchildren.

Mr. Shaffer, who came to Washington to serve in the Justice Department under Democratic Attorney General Robert F. Kennedy, said his defense of Dean, who exposed wrongdoing in a Republican-led administration, was a matter of constitutional principle, not partisanship.

“I have no vendetta against the president,” Mr. Shaffer said in 1973. “I voted for him, and I would vote for him again tomorrow against that fellow who ran against him.”