President Reagan agreed yesterday to curtail his military buildup and limit Social Security benefit increases in exchange for deep domestic spending cuts as part of an agreement with Senate Republicans to reduce deficits over the next three years.

The agreement is aimed at cutting current budget deficits of more than $200 billion a year to less than $100 billion annually by fiscal 1988. Next year's deficit would be cut by $52.1 billion, to $175.3 billion.

Under current projections, inflation adjustments for Social Security would probably be cut by half, and Reagan's proposed after-inflation military spending release also would be halved.

In both the agreement and a defense authorization bill approved yesterday by the Senate Armed Services Committee, defense spending would be allowed to grow by 3 percent after accounting for inflation in each of the next three years, less than half the total that Reagan proposed for the period.

Deficit reductions from defense would amount to $70 billion more than Reagan proposed for the three-year period, and deficit reductions from domestic programs would be $152 billion over three years, starting with about $30 billion next year in comparison to $9 billion from defense.

Federal pay would be frozen for a year, rather than cut by 5 percent as Reagan had proposed. The federal work force would be reduced by 50,000 over three years, and inflation adjustments for federal pensions, both military and civilian, would be restricted in the same fashion as Social Security, probably to no more than 2 percent a year over the period.

A total of 17 programs would be killed, including Amtrak rail passenger service subsidies, Job Corps Urban Development Action Grants, Small Business Administration, Economic Development Administration, Appalachian Regional Commission, Export-Import Bank direct loans, upper-income subsidies for school lunches, federal "impact aid" for local school districts, and most federal postal subsidies. Revenue sharing with local governments would end after next year.

About 30 other programs, including Medicare, Medicaid, farm supports, student aid, highway assistance, housing subsidies, transportation aid and a variety of other social programs would be cut in varying degrees, some substantially.

In exchange for relenting on defense and Social Security, Office of Management and Budget Director David A. Stockman said Reagan got 90 percent of the basic or structural changes he wanted in federal programs and 75 percent of the dollar savings he wanted from domestic programs.

But the agreement to limit cost-of-living increases for Social Security benefits contrasts sharply with the impression left by Reagan during last year's campaign that he would not touch the popular retirement program as part of his campaign to reduce government spending.

Benefits currently rise along with the Consumer Price Index, as long as it grows by more than 3 percent. Under the agreement, beneficiaries would get a 2 percent increase regardless of the inflation rate, along with an amount equivalent to inflation exceeding 4 percent if the CPI increase for a year exceeds 4 percent.

If inflation is 4 percent over the next three years, as the government expects, the cost-of-living increase would thus be cut in half: from 4 percent to 2 percent. This would save $21 billion over three years, roughly the same as the one-year freeze approved earlier by the Senate Budget Committee and opposed by Reagan.

The Social Security compromise was the last part of the package to be agreed upon, and Senate sources indicated that the 2-percent formula was an idea that originated in the White House. Stockman said the president agreed to it only reluctantly as "necessary to glue the package together."

The plan, which sharply revises a draft approved last month by the Senate Budget Committee, cutting defense less and domestic programs more, is scheduled to go to the Senate floor the week of April 22.

It is expected to run into serious difficulties, although Senate Majority Leader Robert J. Dole (R-Kan.) said he thought there was a "good chance" the Senate would pass it "or something like it."

Stockman was less sanguine. "This is going to be the most difficult imaginable proposition to pass in the Senate," let alone the Democratic-controlled House, the president's budget director said.

However, both Dole and White House chief of staff Donald T. Regan said Reagan's support for the budget compromise was wholehearted, dispelling earlier suggestions that he might approve only parts of it or withhold active suppport.

"The president is committed to this package, and he intends to fight for passage in both houses," said Regan. "The president is fully on board . . . he is enthusiastic," said Dole.

Dole put out a bid for Democratic support for the plan, but Minority Leader Robert C. Byrd Jr. (D-W.Va.) was noncommittal in response, saying Democrats "look forward" to a public debate on the proposals.

Sen. Daniel P. Moynihan (D-N.Y.) vowed to fight the Social Security cutback, calling it a "breach of an understanding" on the part of the Republicans and asserting that it would force one million retirees below the poverty line by the end of the decade. The cost to the average retiree over five years would be $1,320, he said.

In some areas, advocates of particular programs were able to exert some damage-control, as in the case of guaranteed student loans, where Reagan's proposed family income limitation for subsidized loans was nearly doubled to $60,000 and the total amount of aid for which a student is eligible was liberalized.

A laborious compromise worked out earlier by the Senate Budget Committee was used as the basis for the negotiations with the White House. But in many areas, yesterday's agreement reached far beyond what the Budget Committee had proposed, as in the case of Medicaid, where proposed cuts totaling nearly $5 billion over a period of three years were several times deeper than the committee had approved.

For Medicare, the compromise basically went along with what the Budget Committee had proposed, including a freeze on doctors' and hospitals' fees and increased out-of-pocket costs for patients for medical services. Medicare cuts would total $18.4 billion over three years, the largest single area of cost reduction outside of Social Security.

The only major area where the compromise cut less than the Budget Committee recommended was defense. For defense, the committee had proposed to allow spending to grow only to cover costs of inflation.

In discussing the defense compromise, Regan said he thought that the savings could be made without affecting any major weapons programs.

The deficit reductions envisioned in the plan are $52.1 billion in fiscal 1986, $99.5 billion in fiscal 1987 and $143.9 billion in fiscal 1988, for a cumulative total of $295.5 billion over the three-year period. According to figures used in the negotiations, these reductions would leave deficits of $175.3 billion, $145.3 billion and $99.7 billion in each of the three years.

Regan called it the "most ambitious budget reduction plan in postwar history," outstripping even Reagan's spending retrenchment plans of previous years.