Mr. Gallagher, left, served in the U.S. House of Representatives from 1959 to 1973. (Charles Gorry/AP)

Former congressman Cornelius E. Gallagher, a New Jersey Democrat who used his clout to protest the erosion of privacy for Americans, ruefully calling the United States a “nation of snoopers,” before losing his seat amid redistricting and allegations of tax fraud and other scandals, died Oct. 17 at his home in Monroe Township, N.J. He was 97.

The cause was glioblastoma, a form of brain cancer, said his daughter Patrice Maillet.

Mr. Gallagher served in the House from 1959 to 1973, representing the cities of Elizabeth, Linden and Rahway in Union County and Bayonne in Hudson County, and was what the Almanac of American Politics described as “one of the finest products” of the Hudson County political machine.

An Army veteran of World War II and the Korean War, he received two awards of the Bronze Star Medal and three awards of the Purple Heart. In Congress he held seats on the Appropriations and Foreign Affairs committees and accumulated a solidly liberal voting record. He was an early supporter of then-Sen. John F. Kennedy (D-Mass.) in his bid for the presidency in 1960 and was mentioned as a possible vice-presidential running mate for President Lyndon B. Johnson in 1964.

Mr. Gallagher “represented the best of New Jersey Democratic politics” in the late 1960s and early 1970s, helping to make “the New Jersey delegation one of the most formidable in the House,” Ross K. Baker, a professor of political science at Rutgers University, wrote in an email.

Some members of the delegation “went on to greater things; others to ignominy. Sadly, Neil Gallagher was one of the latter,” Baker continued. “At his noblest, Gallagher was a champion of the rights of American citizens to privacy. He served his country gallantly in World War II but succumbed to the corrosiveness of New Jersey’s environment of official corruption.”

U.S. citizens, Mr. Gallagher contended, were being slowly stripped of their civil liberties by invasive federal agencies, “big computers” that collected personal data and businesses that used such tools as cameras and two-way mirrors to guard against shoplifting and bank robbery.

On the Committee on Government Operations, he chaired a subcommittee on the invasion of privacy. He introduced legislation to severely curtail government use of polygraph tests, which he considered unreliable.

Mr. Gallagher’s political career turned rocky in 1968, when an article in Life magazine depicted him as a “tool and collaborator of a Cosa Nostra ganglord.” According to the report, which cited wiretapped phone conversations, Mr. Gallagher had used his authority to shield the gambling operations of New Jersey mafioso Joseph “Bayonne Joe” Zicarelli from police investigation and had called on the Mafia to dispose of the body of a loan shark who died in Mr. Gallagher’s house.

Mr. Gallagher fiercely denied those allegations and others printed in the magazine account, insisting that the loan shark had never been in his home “dead or alive” and telling the New York Times that the reported wiretap transcripts were “totally manufactured.” He was reelected easily that year and again in 1970.

His final term in Congress proved more tumultuous.

In April 1972 Mr. Gallagher was indicted on charges of attempting to evade $102,000 in income taxes, perjury stemming from grand jury testimony and a conspiracy with local New Jersey officials to obscure kickbacks. He insisted on his innocence and said that the charges should alarm “anyone who disagrees with the new Caesars in America.”

Later that year, after redistricting combined his district with another, Mr. Gallagher lost to Rep. Dominick V. Daniels in the primary, who went on to win reelection in November.

After his charges were announced, Mr. Gallagher gave an address on the House floor in which he charged that the FBI was corrupt “at the highest level” and decried a “secret police society” that had outlaid “$11 million to destroy me” because of his work on civil liberties, according to the Times.

In late 1972, after an initial not-guilty plea, Mr. Gallagher pleaded guilty to tax evasion. He served 17 months in prison.

“Mr. Gallagher’s personal tragedy is heightened by his generally excellent record in Washington,” the Times wrote in an editorial after his guilty plea. “Always articulate, often enlightened and politically courageous in his positions on public issues, he was respected by his colleagues and seemed qualified for even higher elective office. All of this is ashes now.”

Cornelius Edward Gallagher was born in Bayonne on March 2, 1921. His father was a detective and died when Mr. Gallagher was 8 years old.

Mr. Gallagher interrupted his studies at John Marshall College, now part of Seton Hall University in South Orange, N.J., to serve in the Army during World War II, commanding an infantry rifle company. He received a bachelor’s degree in 1946 and a law degree in 1948, later rejoining the Army to serve in the Korean War. He attained the rank of captain.

Mr. Gallagher began his legal career in private practice in Bayonne. He served on the Hudson County Board of Freeholders in the early 1950s, stepping down to serve on the New Jersey Turnpike Authority. After leaving Congress, he pursued a career in business.

His wife of six decades, the former Claire “Rick” Richter, died in 2004. Their daughter Diane Brennan died in 2013. Survivors include three daughters, Christine Forte of Monroe Township, Patrice Maillet of Freehold, N.J., and Bridget Davis of Rye, N.Y.; 11 grandchildren; and seven great-grandchildren.

In 1995, Mr. Gallagher again found himself in legal jeopardy. He pleaded guilty to charges of tax fraud, stemming from his failure to report $90,000 in profits on the sale of a villa in the Dominican Republic, and bank fraud, related to his efforts to help his then-son-in-law secure a $200,000 loan.

When he was sentenced to 10 months in prison on those ­charges, he denounced “the undying enmity” of agencies including the FBI for his woes.