For more than 40 years, Andrew W. Marshall presided over a little-known office deep in the bowels of the Pentagon as the Defense Department’s designated deep thinker. A civilian scholar who had never served a day in uniform, he was charged with pondering the imponderable and with devising the country’s long-range strategies for fighting — and surviving — future wars.

Drawing on a variety of disciplines, from statistics and business management to nuclear physics, he was credited with foreseeing the collapse of the Soviet Union and with prodding reluctant U.S. leaders to adapt to changing military and technological needs.

Mr. Marshall, who guided the Defense Department’s Office of Net Assessment for 42 years, had access to the nation’s most sensitive intelligence secrets and worked directly for the secretary of defense. He was known for challenging established ways of thinking and for acquiring a reputation as the Pentagon’s “Yoda,” after the wise, gnomic Jedi master of “Star Wars.”

“He had an uncanny ability to pick out only the most significant questions, then to drill down deeply,” Michael Pillsbury, a colleague of 45 years, said in an interview. “He developed an iconoclastic, contrarian image.”

Mr. Marshall inspired such loyalty and near-reverent devotion that his former staffers called themselves graduates of “St. Andrew’s Prep.” He was 97 when he died March 26 at a hospice facility in Arlington, Va.

The death was confirmed by Jeffrey McKitrick, a friend and former employee. He was present at Mr. Marshall’s bedside when he died but said he could not cite a specific medical cause.

One reason Mr. Marshall was held in such esteem was his sheer longevity: He had been studying U.S. military strategy since 1949, at the beginning of the Cold War, and retired at 93 in 2015. He worked for years at the Rand Corp., a California think tank associated with the military, and had witnessed nuclear explosions in the 1950s before coming to the White House in 1969 as an aide to then-National Security Adviser Henry Kissinger.

Notable deaths in 2019: Elijah Cummings, Cokie Roberts, Toni Morrison and others we have lost this year

Don Imus | Don Imus, who spent more than half a century in radio and television skating along the edge of propriety and occasionally falling into the abyss of the unacceptable, died Dec. 27 at a hospital in College Station, Tex. He was 79. In a roller-coaster career in which he grew chummy with prominent politicians, repeatedly got suspended or fired for offensive cracks, abused drugs and touted health foods, Mr. Imus won a loyal following, made millions and transformed himself from a bad-boy DJ into a host whose program became a nearly mandatory stop for presidential candidates. Read the obituary (Richard Drew/AP)

In 1973, Secretary of Defense James R. Schlesinger, Mr. Marshall’s onetime colleague at Rand, created the Office of Net Assessment and put Mr. Marshall in charge. (The term “net assessment” derived from studies of nuclear war, including estimates of casualties and damage.)

“We tend to look at not very happy futures,” Mr. Marshall once told The Washington Post.

He brought an innovative approach to long-range military planning, including the use of business models of corporate competition to describe how powerful countries seek to gain geopolitical advantage over one another. He looked to history to see how advances in technology were reflected on the battlefield.

“What’s amazing,” he told the New Yorker in 2006, “is how much we know, it turns out, about the chariot revolution back in 1700 B.C.”

He distributed more than $10 million each year in grants to think tanks, universities and defense contractors to imagine future conflicts, then devised “war games” to test hypothetical military strategies.

Mr. Marshall had a staff of only about 10 analysts, including military officers and civilians, working in windowless offices on the third floor of the Pentagon. They held the highest levels of security clearance.

“His approach was always to focus on the question,” McKitrick, a defense researcher who worked for Mr. Marshall in the 1980s, said in an interview. “Too often, people focus on solutions but haven’t identified the right questions. He thought it was very important to get the strategic questions right and then start thinking about the answers.”

Mr. Marshall received intelligence reports from the CIA and Defense Department and gauged future military needs against what he learned about U.S. adversaries.

“One of the things that happens from time to time ,” he told Armed Forces Journal in 2011, “is that you have to revise your entire notion of how your opponent sees things.”

During the Cold War, the conventional Pentagon thinking was that a Soviet nuclear attack would be aimed at major cities.

“We assumed the Soviets were like us and that they would like to destroy our cities,” Pillsbury said. “No, they wanted to destroy our command-and-control systems,” targeting military and political leaders.

As a result, billions of dollars were spent to strengthen emergency bunkers and to improve communications networks.

In the waning years of the Cold War, Mr. Marshall was among the first to suggest the Soviet Union’s crumbling infrastructure and failing economy foretold the country’s imminent collapse.

By then, Mr. Marshall had turned his attention in a different direction, following the adage that military leaders are always prepared to the fight the last war, not the next one. His view was that, as the world changed, the nature of warfare should change with it. In the 1990s, he recommended that military leaders shift their focus to China as the greatest long-term threat to U.S. preeminence.

In a 1993 memo called “Some Thoughts on Military Revolutions,” Mr. Marshall called for a “revolution in military affairs,” emphasizing a smaller, more mobile strike force and greater reliance on information technology. (Mr. Marshall did not use computers or email himself.)

During the administration of President George W. Bush, Defense Secretary Donald H. Rumsfeld called on Mr. Marshall to lead a comprehensive review of military readiness. Rumsfeld’s recommendation of a smaller, nimbler military came directly out of Mr. Marshall’s thinking.

Critics, however, noted that Mr. Marshall underestimated the social impact of the Internet and failed to anticipate the role of terrorism in the attacks of Sept. 11, 2001.

“You can never account for black swans, and 9/11 was a black swan,” McKitrick said. “There is a difference between predictions and forecasting.” Mr. Marshall, he added, “was about strategic forecasting.”

Andrew Walter Marshall was born Aug. 13, 1921, in Detroit. His father was a stonemason, his mother a homemaker; both parents were immigrants from England.

As a child, Mr. Marshall was an eager reader with an interest in the military and history. He received a medical deferment during World War II because of a heart murmur and worked at an aircraft factory.

He attended Wayne State University in Detroit and, despite not having a bachelor’s degree, was admitted to graduate school in economics at the University of Chicago, where he received a master’s degree.

At the Rand Corp., his colleagues included futurist Herman Kahn — the best man at his wedding — and Daniel Ellsberg, who released the Pentagon Papers to news organizations, revealing the early history of the Vietnam War.

In those years, Mr. Marshall worked on early-warning systems and other ways to reduce the likelihood of nuclear attack.

His first wife, the former Mary Speer, died in 2004 after more than 50 years of marriage. His second wife, Ann Wheeler Smith, died in 2017. He had no immediate survivors.

Mr. Marshall was a political appointee who often expected that a change in administration would send him packing. (He never sold his house in California, expecting that eventuality.) In 1997, Defense Secretary William Cohen attempted to have him transferred out of the Pentagon, but the outcry was so strong that Mr. Marshall stayed put for another 18 years.

After he retired, Mr. Marshall continued to consult with military experts until a week before his death.

Mr. Marshall’s office prepared more than 20 “net assessments” of future military strategies, each looking 10 to 20 years into the future. He delivered the reports by hand to the secretary of defense, carrying them in a zippered bag made of fireproof fabric. Only one copy was made of each report, which Mr. Marshall then kept locked in his office.

He is the only person known to have read all the reports, which remain classified to this day.