Caspar W. Weinberger, who held high positions under three Republican presidents and oversaw the biggest and costliest military buildup in peacetime history as Ronald Reagan's secretary of defense, died yesterday in Bangor, Me., after a brief illness. He was 88.

Mr. Weinberger lived nearby in Mount Desert, Me. His son, Caspar Jr., also of Mount Desert, said his father had been undergoing kidney dialysis for two years and died of pneumonia. His wife of 63 years, Jane, was by his side when he died, his son said.

Until his death, Mr. Weinberger was chairman of Forbes Inc. He had continued to travel around the world until recently, his son said, and wrote a regular column for Forbes magazine. A book by Mr. Weinberger, "Home of the Brave: A Tribute to Unsung Heroes in the War on Terror," which he wrote with Wynton C. Hall, will be published in June by Forge Press.

A self-assured man and a tenacious debater, Mr. Weinberger served in Washington off and on for almost two decades. He was a crucial backer of Mr. Reagan's missile-based Strategic Defense Initiative, popularly known as Star Wars. He was also an implacable foe of the Soviet Union, a posture that put him increasingly at odds with Secretary of State George P. Shultz, who leaned more toward arms-control negotiations with Moscow.

By the time Mr. Weinberger left the Pentagon in 1987, Mr. Reagan had been swayed by Mr. Shultz (who had the president's wife, Nancy, in his corner). The president who had once derided the Soviet Union as "an evil empire" got along well with the Russian leader, Mikhail S. Gorbachev, who seemed cut from different cloth than his drab but ruthless predecessors.

Mr. Weinberger never lost his bone-deep suspicion of the Russians, and his comments after the collapse of the Soviet Union suggested that he still had more faith in arms than diplomacy, at least in dealing with the Kremlin.

Many felt that Mr. Weinberger's record was marred late in life by questions about his role in the Iran-contra affair — questions a presidential pardon left unresolved — but his résumé was impressive by any standard.

Under President Richard M. Nixon, he was chairman of the Federal Trade Commission; deputy director and later director of the Office of Management and Budget, where he earned the nickname Cap the Knife by smilingly arguing against requests for more money; and secretary of health, education and welfare.

He remained as secretary of the health and welfare agency under President Gerald R. Ford until 1975, when he left Washington for his native California. He said his wife could better cope with her arthritis there.

It was after he returned to the capital as defense secretary for Mr. Reagan in 1981 that Mr. Weinberger made his real mark. His mission, he said early on, was "to rearm America." His view was that previous efforts to get along with the Russians without demanding good behavior in return had reinforced "the Soviet prison wall," which stretched, he said, "from the Balkans to the Baltic."

The rise of the charismatic Mr. Gorbachev in the mid-1980's did not soften those views. "I don't think just because he wears Gucci shoes and smiles occasionally that the Soviet Union has changed its basic doctrines," Mr. Weinberger said in 1987, as he was leaving office.

So while other parts of the federal government were cringing under the cut-to-the-bone philosophy of the Reagan White House (as the old Cap the Knife might have desired), Mr. Weinberger demanded billions more for nuclear arms, ships, planes and tanks. "This is not a one-year program for summer soldiers," he warned in 1981.

He was true to his word. Year after year, he fought for big increases in Pentagon spending and usually won.

Mr. Weinberger also tried to alleviate the historic rivalries among the services. He ordered the branches to find more roles for women. He delegated more planning authority to the chiefs of staff and the service secretaries so that he could devote more time to policy.

A blemish in his 35 years of public service came in 1992, five years after he left the cabinet. That year, he was indicted on felony charges of perjury and obstruction of justice in connection with the covert sale of arms to Iran and the diversion of some of the proceeds to the Nicaraguan rebels, or contras.

The tangled transactions, which came to be known as the Iran-contra affair, were against the declared policy of the United States. Subsequent investigations depicted Mr. Reagan as determined to win the release of American hostages held in the Middle East and eager to obtain the help of Iranian "moderates" to do so.

Mr. Weinberger told a special committee of Congress in 1987 that he was aghast when he first heard White House aides talk about cultivating Iranian moderates. He testified that he had considered the idea "almost too absurd to comment on," and he said as much in a staff memorandum at the time. He told Congress that he thought, erroneously, that he had killed the proposal.

A special commission headed by John Tower, a former Republican senator from Texas, criticized Mr. Weinberger as not advising the president vigorously enough. Mr. Weinberger rejected the criticism as unfair.

The special Iran-contra prosecutor, Lawrence E. Walsh, obtained an indictment accusing Mr. Weinberger of concealing voluminous notes that would have cast more light on the roles of Mr. Reagan and Vice President George Bush in the scandal. The notes were scrawled in his almost illegible handwriting in some 5-by-7-inch notebooks that he had donated to the Library of Congress after leaving office.

The notebooks, some 1,700 of them, lay undisturbed until prosecutors learned of them. To Mr. Weinberger and his supporters, the little books were personal diaries, with jottings about the family dog as well as policy. To prosecutors, they were evidence the former secretary had tried to bury.

Mr. Weinberger furiously denied the charges, declaring that the prosecutor had pressed him to plead guilty to a lesser count in return for giving damaging testimony against Mr. Reagan, testimony that Mr. Weinberger said would have been false.

Mr. Weinberger was to have stood trial in 1993. But on Christmas Eve 1992, President George Bush ended Mr. Weinberger's legal troubles, pardoning him and several other officials caught up in the scandal.

Early in his tenure as defense secretary, Mr. Weinberger learned that he could not change the sprawling military bureaucracy overnight. In 1981, David A. Stockman, the Reagan budget director, pronounced the Pentagon "a swamp" of waste and inefficiency.

"Maybe he was talking about the Pentagon of a few years ago," Mr. Weinberger bristled. "The Pentagon is not a swamp. It is very dry land."

But two years later, Mr. Weinberger acknowledged that some spending absurdities had sprung up under his watch as well as under previous Democratic ones. A common metal bolt that cost 80 cents in 1980 had somehow become worth $17.59 in 1982, for instance.

Though he oversaw the spending of huge sums as Pentagon chief, Mr. Weinberger sometimes unleashed the budget-cutter in his political personality. Shortly after asking for $30 billion more in military spending for the first two years of the Reagan administration, he announced $1.7 billion in spending cuts through elimination of some projects and postponement of others.

In 1985, he canceled the development of an antiaircraft gun that had already cost $1.8 billion and was expected to cost $3 billion more. It just did not work very well, and there was no use throwing good money after bad, the secretary said.

Mr. Weinberger was soft-spoken, almost courtly in personal encounters. He showed a soft side in 1983, when he vetoed a plan for dogs to be shot so that military doctors could practice treating wounds. (He owned a collie at the time.)

By mid-1985, there were signs that his influence was waning. Some Congressional leaders had wearied of his demands for more and more money, and he was conspicuously omitted from Mr. Reagan's entourage to the Geneva summit meeting with Mr. Gorbachev.

Mr. Weinberger resigned on Nov. 5, 1987. His wife had undergone treatment for cancer, and he said he wanted to spend more time with her at home. "That's the long and the short and the tall of it," he said.

Not everyone believed him entirely. By many accounts, Mr. Weinberger differed often with Secretary of State Shultz, whom he considered too eager to negotiate with the Kremlin. And some of Mr. Weinberger's critics thought it was no coincidence that his resignation came just weeks after the stock market plunged, heralding a time of retrenching and the end of the Pentagon joy ride.

Caspar Willard Weinberger was born in San Francisco on Aug. 18, 1917. His father, Herman, was of Jewish Bohemian descent and worked his way through college to become a lawyer. His mother, Cerise, was from an English background. In his book "In the Arena: A Memoir of the 20th Century," written with Gretchen Roberts and published by Regnery in 2001, Mr. Weinberger said his father and grandfather had been indifferent to religion but that he himself had found his mother's Episcopalian faith "an enormous influence and comfort all my life."

Mr. Weinberger graduated magna cum laude from Harvard, where he was a member of Phi Beta Kappa, in 1938. He graduated from Harvard Law School in 1941 and enlisted in the Army the same year. Decades later, when men with stars on their shoulders had to defer to him, he ruefully recalled that one of his first jobs in the Army was at a camp in California digging ditches for sewers.

Mr. Weinberger went to officers' candidate school at Fort Benning, Ga., was sent to the Pacific after being commissioned, served more than three years with the 41st Infantry Division and landed on the intelligence staff of Gen. Douglas MacArthur.

He was a clerk for a federal judge from 1945 to 1947, then started a private practice in the San Francisco area. He broke into politics in 1952, winning a seat in the California Assembly. He was re-elected without opposition in 1954 and 1956. A 1955 poll of newspaper reporters who covered the Legislature selected him as the most able California lawmaker.

Mr. Weinberger was defeated in a run for attorney general of California in 1958. From 1959 to 1968, he wrote a newspaper column on state government and was moderator of a public affairs television program. He was vice chairman of the Republican State Central Committee of California from 1960 to 1962 and chairman from 1962 to 1964.

Mr. Weinberger was chairman of a commission on reorganizing the California state government from 1966 to 1968 and was appointed state director of finance by Mr. Reagan, then the governor, early in 1968. The two had a warm relationship, even though in 1966 Mr. Weinberger had opposed Mr. Reagan in favor of a fellow San Franciscan in the Republican primary for governor. Mr. Weinberger was also considered a turncoat by some conservative Republicans because he gave only token support to Barry Goldwater's presidential campaign in 1964.

As California's finance director, Mr. Weinberger ran an office that had long been considered weak in the state government. By most accounts, he revitalized it.

Around that time, he was asked to sum up his political philosophy. He replied with a Republican bromide, "Liberal on human affairs and conservative on fiscal ones."

His service under Mr. Reagan in California, and their friendship, burnished Mr. Weinberger's credentials in conservative eyes, enough so that Nixon asked him to be chairman of the Federal Trade Commission. Taking office in January 1970, Mr. Weinberger promised to be an ally to consumers.

To the annoyance of some conservatives in the administration, Mr. Weinberger took on as an aide William Howard Taft 4th. Mr. Taft had the right name and the right Republican pedigree, but some businessmen thought he had a blemish on his résumé: he had been an investigator for Ralph Nader. (Mr. Taft later served as a deputy defense secretary under Mr. Weinberger.)

In the summer of 1970, Nixon named Mr. Weinberger deputy director of the new Office of Management and Budget. When the director, Mr. Shultz, became Treasury secretary in May 1972, Mr. Weinberger took Mr. Shultz's old job.

In November 1972, Nixon needed a new secretary of health, education and welfare to replace Elliot L. Richardson, who had moved to secretary of defense. Mr. Weinberger was a natural for the post, in view of Nixon's stated opinion that the health agency had become "bloated."

Democrats wondered, in the words of Senator Harold E. Hughes of Iowa, if Mr. Weinberger could "make the transition from budget hatchetman to advocate of people programs." He was confirmed by a vote of 61 to 10.

As his critics had predicted, Mr. Weinberger did try to kill or rein in dozens of programs, including some for hospital construction and school aid. But his stewardship was not marked by the wholesale federal retreat on health issues that some liberals had feared.

One reason was that Mr. Weinberger embraced some causes that liberals (and not a few conservatives) liked. He tried to get Congress to pass legislation limiting the tar and nicotine content of cigarettes. He envisioned national health insurance. He prodded his own department to protect the civil rights of mentally retarded people who were considered for sterilization. And at his insistence, a better American diet became official departmental policy.

Another reason he could not live up to his sobriquet of Cap the Knife as H.E.W. secretary was that much of the department's spending was simply beyond his control. The enormous sums paid out for Social Security, Medicare and welfare programs were fixed by law, and often included automatic cost-of-living increases.

So in the end, Mr. Weinberger presided over an expansion at the department, an irony that prompted him to warn upon his departure of the perils of big government.

After resigning from the Ford administration in 1975, Mr. Weinberger became a special counsel to the Bechtel engineering companies. As president-elect, Mr. Reagan turned to him in 1980 for advice on economic issues, opening the door for his career-culminating tenure at the Pentagon.

Mr. Weinberger's novel, "Chain of Command," written with Peter Schweizer, was published by Artia Books, a subsidiary of Simon & Schuster, in 2005. He was also the co-author, with Mr. Schweizer, of "The Next War," an examination of defense strategy, published by Regnery in 1996.

Mr. Weinberger enjoyed the theater, opera and ballet and for a time reviewed books for California newspapers.

In addition to his wife and son, he is survived by a daughter, Arlin Weinberger; three grandchildren; and four great-grandchildren.

Mr. Weinberger was second only to Robert S. McNamara in longevity as defense secretary. Characteristically, he fired some parting shots in his farewell ceremony on Nov. 17, 1987, complaining that previous presidents and lawmakers had allowed the American military to become weak and flabby.

"We began by doubting the war in Vietnam," he lamented, "and we ended by doubting ourselves."

Not even his bitterest foes doubted his patriotism or his intellectual power. But many critics thought he had encouraged Pentagon spending that was wasteful by any standards.

In the summer of 1993, a three-year study by the General Accounting Office, an investigative arm of Congress, concluded that under Mr. Weinberger the Pentagon had understated the cost of some weapons by billions of dollars, overstated their effectiveness and exaggerated the threat of the Soviet Union.

Deriding the study as revisionist history written by bean-counters, Mr. Weinberger said its authors showed no understanding of how the world really was in the cold war era.

"Yes, we used a worst-case analysis," he said. "You should always use a worst-case analysis in this business. You can't afford to be wrong. In the end, we won the cold war, and if we won by too much, if it was overkill, so be it."

Maria Newman contributed reporting for this article.

Copyright 2006The New York Times Company