Ralph Hall, at his home in 2014 in Rockwall, Tex., served in the U.S. House of Representatives for 34 years. A longtime Democrat, he joined the Republican Party in 2004. (LM Otero/AP)

Ralph M. Hall, a Democrat-turned-Republican from Texas who was elected 17 times to Congress, where he became dean of his state’s delegation, one of the last veterans of World War II on Capitol Hill and the oldest person in history to serve in the U.S. House, died March 7 at his home in Rockwall, Tex. He was 95.

His longtime political strategist, Ed Valentine, confirmed the death and said he did not know the cause.

A former Navy pilot and Texas state senator, Mr. Hall was elected to the House in 1980 as a Democrat and for the next 34 years — the final decade as a Republican — represented a swath of the Red River Valley in eastern Texas. He announced that his 2014 campaign would be his last and was defeated in the Republican primary by John Ratcliffe, a former U.S. attorney who pledged to serve no more than eight years.

From his early years in Washington, Mr. Hall established a voting record that reflected a district leaning increasingly toward the GOP. At times, according to the Almanac of American Politics, he held the most conservative voting record among House Democrats.

In the 1980s, he backed the budget and tax cuts pushed by President Ronald Reagan, a Republican. In the ’90s, Mr. Hall supported the impeachment of President Bill Clinton, a Democrat, and voted against the North American Free Trade Agreement, a centerpiece of Clinton’s domestic platform.

Mr. Hall supported much of the Contract With America, the agenda presented by Newt Gingrich (R-Ga.), who led Republicans in recapturing the House in 1994 after decades of Democratic control. When Democrats retook the majority in 2006, Mr. Hall declined to vote for Rep. Nancy Pelosi (D-Calif.) as House speaker.

Mr. Hall stayed in the Democratic Party, he said, so that he could help bring it “back toward the middle.” He held prominent positions on the Energy and Commerce Committee, where he represented oil and gas industrial concerns important to Texans, and on the Science Committee, where, as a top-ranking member, he was an advocate for the space program.

In 2004, after nearly a quarter-century as a Democratic congressman, Mr. Hall announced that he was joining the Republican Party. “I’m not comfortable in the caucus with them running down a president that I’ve known since he was 11,” he told the New York Times, referring to George W. Bush.

Mr. Hall remained in office for another decade — long enough to become, on Dec. 25, 2012, the oldest person ever to serve in the House. The record was previously held by Rep. Charles Manly Stedman (D-N.C.), a Civil War veteran who died in office in 1930 at age 89. When he reached the milestone, Mr. Hall was completing a term as chairman of the Science, Space and Technology Committee.

In 2014, facing five primary challengers, he received 45 percent of the vote and was pushed into a runoff with Ratcliffe. While delicately maneuvering the issue of Mr. Hall’s age, Ratcliffe campaigned on the theme that the congressman had overstayed his time in Washington.

Mr. Hall, meanwhile, spoke openly about his age. In a television ad, he declared his marked wrinkles were scars from political tussles with Pelosi and against gun control and President Obama’s health-care legislation.

“By gosh,” he said, “I’ve got room for a few more wrinkles.”

In the runoff, Ratcliffe defeated Mr. Hall, 53 percent to 47 percent.

Mr. Hall and Rep. John D. Dingell (D-Mich.), who announced in early 2014 that he would retire at the end of the term, were the last veterans of World War II serving in Congress. Dingell died in February.

Ralph Moody Hall was born May 3, 1923, in Fate, a town in Rockwall County, Tex. As a boy, he said, he worked at a pharmacy and encountered customers including the gangsters Bonnie and Clyde.

“They wanted a carton of Old Golds, two Coca-Colas and all the newspapers we had,” he told The Washington Post. “I went and got what they wanted, they gave me $3 and they said keep the change.”

Mr. Hall received a law degree from Southern Methodist University in Dallas in 1951. He later was a lawyer and worked in business before becoming a Rockwall County judge in 1950 and a Texas state senator in 1962. Mr. Hall held that post for a decade before running unsuccessfully for Texas lieutenant governor in 1972. In 1980, he won the U.S. House seat of Ray Roberts (D), who was retiring.

Mr. Hall’s wife of 63 years, Mary Ellen Murphy Hall, died in 2008. Survivors include three sons, Hamp Hall, Brett Hall and Blakeley Hall, all of Rockwall; five grandchildren; and two great-grandchildren.

Mr. Hall once told the Dallas Morning News that “if you are as old as I am, you have to have a gimmick.” His gimmick was a penny — he distributed thousands of them — that read, “Thanks from Ralph M. Hall, U.S. Congressman.”

“Take this good-luck penny to the polls,” he told constituents, “and maybe we’ll both be lucky.”