The Treasury Department's proposal to overhaul the federal tax system was only days old when hundreds of charities, universities, hospitals, museums, ministers, congressmen and philanthropists began to plead with the White House to spare their most cherished tax break: the charitable deduction.

Treasury had proposed to curb the deduction, like dozens of others, on grounds that it drained billions of dollars of revenues and gave the tax code too much influence over such day-to-day decisions as whether people donate art to museums or money to their alma maters.

When Reagan unveiled his tax proposal Tuesday night, the charitable deduction was alive and well -- one of a group of major tax advantages restored by the president to the Treasury blueprint. Speculation immediately focused on Harvard University, the Metropolitan Museum of Art and other influential institutions that lobbied against the proposal, as having turned the tide.

But the battle for the charitable deduction, like many other features of the president's plan, was settled before most of the heavy guns were fired, administration officials said.

In this case, Reagan vetoed any change in the charitable deduction almost as soon as the Treasury proposal was released.

"The president had a very simple, straightforward view," said a senior administration official. "He said this is an administration that wants to encourage voluntarism. Why go in the other direction?"

The five-month process by which the Treasury proposal became Reagan's proposal included dozens of such choices. The White House decided to restore advantages for the oil industry, capital gains, certain kinds of life and health insurance, small businesses, and more. But Reagan held firm in eliminating special tax breaks for timber, real estate and others.

Some decisions were largely political, meaning that Treasury officials figured the package would be defeated unless they compromised. These included restoring the tax-free status of many employe fringe benefits. Sen. Bob Packwood (R-Ore.), chairman of the Senate Finance Committee that rules on tax matters, demanded this as his price for supporting Reagan's package.

Some changes, described as "technical," resulted largely from judgment calls by Treasury Secretary James A. Baker III and aides, who concluded that certain proposals would slow economic growth. The decision to restore the advantage for capital gains fell in this category, although it also had political overtones, several lobbyists and officials said.

And in some cases, the Treasury simply needed more money. The president had insisted that the plan be "revenue neutral," meaning that it should neither raise nor lose federal revenue. But about 10 days before Reagan's speech, Treasury officials discovered that they had restored so many tax benefits to the original proposal that they were about to increase the federal deficit by tens of billions of dollars.

At that point, sources said, senior officials decided to propose a tax on "windfall gains" of corporations that benefited in the past from generous deductions for capital investments. This tax, considered one of the most controversial and innovative features of the plan, probably would not have been proposed if not for the surprise shortfall, according to administration sources.

"It was the last thing we decided. We decided on it last Saturday," said an informed official. "It possibly wouldn't have been in there if we hadn't simply needed the money."

That provision is expected to raise $60 billion in four years.

No feature of Reagan's proposal drew more scrutiny than his decision to restore most tax advantages for the oil and natural gas industry. Treasury had proposed eliminating the percentage depletion allowance for oil and gas and the immediate write-off of certain drilling expenses -- advantages that are expected to save the industry more than $4 billion in taxes next year. These features are widely viewed as symbols of special treatment.

Reagan restored the percentage depletion allowance for small wells and the write-off of drilling expenses for all companies. It was a major victory for independent oil and gas producers, some of them influential Republican campaign contributors who led the lobbying effort. But Treasury officials said this decision, like others, rested on both politics and merit.

Soon after Treasury released its proposal in November, independent oil and gas producers -- the only beneficiaries of depletion since 1975, when Congress denied it to major companies -- converged on Congress, Treasury, the Republican Party, and even on Reagan. They argued that national security was at stake because, without their tax breaks, they would drill fewer wells and thus would find less oil.

Behind the scenes, they also flexed political muscle. One official said that 75 Republican "Eagles" -- the nickname for those who gave more than $10,000 to the party -- from oil states informed Republican National Committee Chairman Frank Fahrenkopf that he could not count on their contributions again unless the president restored the tax advantages for oil and gas.

The group's special access was evident from the start. A number of Oklahoma producers, escorted by Sen. Don Nickles (R-Okla.), met with Reagan in February to make the national security pitch. Others met with Baker, a Texan with longtime exposure to oil industry concerns. The Independent Petroleum Association of America coordinated a lobbying campaign and won the Energy Department's support.

But, as with charitable deductions, administration officials said the oil and gas decision was made early on -- long before Energy Secretary John S. Herrington went to bat for the industry. Reagan adopted the national security argument and said in numerous meetings with advisers that he had to "do something for" the independent drillers, administration officials said.

Another major change restored the favored treatment of capital gains and effectively lowered the top rate from 20 percent to 17.5 percent. The first Treasury proposal had lambasted the capital gains break as one that gave certain investments advantages over others, and encouraged tax shelters.

This provision prompted a powerful lobbying campaign by the American Business Conference and the American Electronics Association, representatives of high-tech and high-growth industries, which attract much of their investment because of the capital gains advantage and whose officers include numerous prominent Republicans.

Again, as with the charitable deduction, this battle was over almost before it was fought, officials said. A senior administration official who helped shape the final package said that he and others simply believed Treasury was wrong in proposing to tax capital gains as ordinary income because it would retard investment in one of the most important sectors of the economy.

Other compromises were made, officials said, because the original proposals were expected to produce great controversy while raising little revenue. These included decisions to treat credit unions more generously than originally planned and to allow continued tax exemptions for free housing provided by churches to many ministers