John O. Marsh Jr., a conservative Virginia Democrat who interrupted his congressional career in the 1960s to serve his National Guard duty in Vietnam foxholes, became one of President Gerald Ford’s closest advisers and spent eight years as Army secretary under President Ronald Reagan, died Feb. 4 at an assisted-living center in Raphine, Va. He was 92.

Mr. Marsh had complications from a recent stroke, said his son John O. “Rob” Marsh III.

Although not widely known outside the policymaking corridors of Washington — the New York Times called him one of the longest-serving but “least known” senior officials in the Defense Department — Mr. Marsh was a powerful backstage player at the White House and the Pentagon during the 1970s and 1980s.

He retained the demeanor of the folksy, soft-spoken country lawyer he had been during his early career. But he was also shrewd and subtle — a “careful, almost soulful political operative,” as Washington Post journalist Bob Woodward once described him.

After a hardscrabble upbringing in the Shenandoah Valley, Mr. Marsh became a commissioned Army officer by 19, trained as a paratrooper, served 25 years in the Virginia National Guard and devoted much of his adult life to military affairs.

In late 1966, during his second term in Congress, he volunteered for a month-long stint in the Vietnam highlands, never revealing to other soldiers that he held national office. (He served under the command of then-Lt. Col. Alexander M. Haig Jr., the future four-star Army general who became chief of staff under Presidents Richard M. Nixon and Ford and secretary of state under Reagan.)

On Capitol Hill, Mr. Marsh was a solid supporter of the Vietnam War and co-sponsored the bill that created the American Revolution Bicentennial Commission in 1966. Increasingly ill at ease in a party that was tilting ever leftward, he declined to seek election to a fifth term in 1970.

“They required candidates for office to sign an oath that they would support the national ticket, which I refused to do,” he later told presidential historian Richard Norton Smith. “I was not putting up with that.”

In 1973, Nixon named Mr. Marsh assistant secretary of defense for legislative affairs, essentially the Pentagon’s chief lobbyist to Congress. The next year, he became a top assistant to then-Vice President Ford on national security matters. After Nixon resigned on Aug. 9, 1974, amid the threat of impeachment for Watergate-related offenses, Mr. Marsh spent three years as a Cabinet-level counselor to President Ford.

He was regarded as one of Ford’s most influential aides — the president’s “conscience,” Smith said. “He was the wise man of the Ford administration,” he added, “someone who was steeped in the traditions of the House, someone who enjoyed the confidence of both sides of the aisle, someone seen as not primarily thirsting in ambition. He’d walked away from the House.”

Mr. Marsh’s designated duty was to act as a liaison with Capitol Hill, but he was in practice an ambassador without portfolio. Among other duties, Ford appointed Mr. Marsh to a commission that examined illegal domestic spying and other abuses by the CIA.

But the crisis that most stood out — and defined the Ford White House — was the question of a full pardon for Nixon over his role in Watergate. The matter arose during Nixon’s final week in office, when Ford’s advisers learned that Haig had reached out to Ford about the possibility of a pardon.

Ford said he had made no promises, but in Mr. Marsh’s view, the mere perception of a backroom deal with Haig threatened Ford’s reputation and legacy. The vice president’s top counselors, chief among them Mr. Marsh, told him to call Haig immediately and make clear there would be no arrangement of a pardon.

“I wanted the president to see the linkage” with the Haig visit, Mr. Marsh told author Barry Werth for the book “31 Days,” about the pardon and its aftermath. “I know that Jerry Ford has a naive streak, and it is there because he trusts people and doesn’t see motives that people have.”

Mr. Marsh and other aides went out for drinks that night, imagining they had forestalled a crisis. But a month into his presidency, on Sept. 8, Ford issued a full pardon, explaining to his staff — and later to the public — that he wanted to lance the boil of Watergate and move forward on legislative priorities.

Instead, Ford faced a revolt among Democrats as well as many in his own party. His press secretary, Jerald F. terHorst, a respected journalist, resigned, saying he could not “credibly defend” the pardon.

The pardon, along with deepening economic “stagflation,” contributed to Ford’s defeat in 1976 by former Georgia governor Jimmy Carter (D).

Mr. Marsh, who gradually came to call himself a Republican, spent four years in private practice until Reagan’s presidential victory in 1980 returned the White House to GOP control. Over two terms, Mr. Marsh became the Army’s longest-serving civilian administrative leader in modern times.

Amid Reagan’s arms buildup, Mr. Marsh played a major backstage role in persuading members of Congress to support deploying Pershing II missiles to Western Europe at a time of strong opposition in the United States and abroad.

Some analysts later said the missiles, which could carry nuclear warheads, helped spur negotiations with the Soviets on a 1987 treaty that banned land-based American and Russian intermediate-range missiles — a landmark in Cold War de-escalation.

Mr. Marsh was credited with increasing the Army’s budget substantially and with using his authority to back the budding Special Operations forces (SOF). Many at the Pentagon — and their allies in Congress — supported big-fire weaponry and conventional fighting forces and were suspicious of covert activity by small, elite units.

Withstanding pressure by the service chiefs to defund the units, Mr. Marsh took on the added role of acting assistant secretary of defense for Special Operations to signal his support at a time when the forces had not yet gained a reputation for excellence.

Retired Army Col. Keith Nightingale, who was involved with the initial phases of the U.S. Special Operations program, said the 2011 raid that killed al-Qaeda leader Osama bin Laden , among other successful operations, “was a direct result of Marsh not allowing the Army to disband several crucial elements of the emerging SOF units.”

“Now,” he added, “personalities and attitudes have dramatically changed to where SOF is now the darling child of all the services.”

John Otho Marsh Jr. was born in Winchester, Va., on Aug. 7, 1926, and grew up in Harrisonburg, Va. During the Depression, his family relied mostly on his mother’s salary as a schoolteacher. His father had abandoned medical training after being diagnosed with tuberculosis and went on to run businesses including a gas station and a shoe store.

Mr. Marsh’s time in the Army included service with the post-World War II occupation forces in Germany. On the GI Bill, he received a law degree in 1951 from Washington and Lee University in Lexington, Va., then commenced a career in law and local politics.

With the backing of Sen. Harry F. Byrd Sr., who controlled a statewide political machine, Mr. Marsh won an open congressional seat in 1962.

His wife of 65 years, the former Glenn Ann Patterson, died in 2015. In addition to his son, a combat surgeon for the Delta Force in Somalia, of Middlebrook, Va., survivors include two other children, Rebecca Whitener of Pulaski, Va., and Scot Marsh of Winchester; and seven grandchildren.

Mr. Marsh retired from the National Guard in 1976 with the rank of lieutenant colonel. His honors included the Defense Department Medal for Distinguished Public Service.

In 2007, The Washington Post exposed decrepit conditions, systemic problems with patient care and leadership failures at Walter Reed Army Medical Center in Washington. Soon afterward, Defense Secretary Robert M. Gates named Mr. Marsh and Togo West, who had been Army secretary under President Bill Clinton, to co-chair an independent review group to address The Post’s findings.

Among the panel’s recommendations were shuttering Walter Reed as soon as possible and accelerating its move to the National Naval Medical Center campus in Bethesda, Md.

Mr. Marsh had made patriotism a hallmark of his public service, and one of his principal legacies as Army secretary was reinvigorating a sense of pride in a military still reeling from defeat in Vietnam.

He spearheaded annual morale-building, values-based themes, including the spirit of victory at Yorktown, Va., physical fitness and the year of the noncommissioned officer.

“I didn’t become secretary of the Army,” he told the Times, “to go around hangdog and half ashamed, apologizing for the United States Army in Vietnam, because it needed no apologies.”