Congress last night broke its long, bitter budget impasse and gave final approval to a "better-than-nothing" plan to reduce deficits as it wound up work for the summer and recessed until after Labor Day.

The House approved the compromise, hammered out over the last three days by bargainers from the two chambers, by 309 to 119, with a majority of Republicans and Democrats supporting it. The Republican-led Senate, overcoming its distress over concessions it was forced to make to the House and the White House, then approved it, 67 to 32.

The budget, hailed ambivalently by its drafters as the best that could be achieved under trying circumstances, made the biggest single deficit reduction in history but also left behind deficits of historic proportions.

"Tonight, after having lost the war, we are going to declare victory and go home," said Rep. John Edward Porter (R-Ill.).

Leaving behind a pile of unfinished business, the vacation-bound lawmakers also:

*Approved and sent to the president a $13 billion supplemental appropriations bill that included $27 million to resume aid to antigovernment rebels in Nicaragua after a year's interruption.

*Put off final action on a package of economic sanctions against South Africa until September because of a tie-up in the Senate. The House signed off on the sanctions bill by a vote of 380 to 48.

*Continued their disarray over new farm legislation, with the House Agriculture Committee struggling unsuccessfully to report out a bill that they could show their farmer constituents during the recess, and senators engaging in partisan bickering over their failure to agree on a bill. Details, Page A9.

But it was the budget that dominated the first six months of the 99th Congress, and both chambers echoed with sighs of relief at its expected adoption, along with some shudders of dismay at the results.

Amid warnings that deficits would continue at dangerously high levels despite extensive spending cuts, the budget negotiators approved by voice a $967.6 billion budget for fiscal 1986 as part of a spending blueprint that claims nearly $280 billion in deficit reductions over three years.

First-year reductions in the deficit were calculated at $55.5 billion by the Senate and $57.5 billion by the House.

The plan officially projected that deficits would fall from $210 billion this year to $112 billion by fiscal 1988 -- somewhat shy of the goal set by both the administration and congressional leaders of cutting deficits by more than half to less than $100 billion over that period.

But other estimates, including one from the Congressional Budget Office based on less rosy economic projections, projected the fiscal 1988 deficit at $161 billion, which is nowhere near the target figure.

The CBO-based calculations also pegged the value of the deficit reductions at $39 billion for next year and $200 billion over three years, considerably less than claimed in the budget.

With President Reagan having ruled out tax increases and Social Security cutbacks, the deficit reductions would come from squeezing most domestic spending programs for a fifth year in a row and from leveling off the president's military buildup for the first time.

The balance between defense and domestic cutbacks is vastly different from what Reagan proposed. Defense bore a far bigger share of the savings than he wanted, largely because of resistance in both chambers -- but especially in the Democratic-controlled House -- to a continuation of Reagan's military buildup at the expense of popular domestic programs.

Defense accounts for about one-half the three-year savings, or $137 billion. Domestic program cutbacks account for most of the rest, $92.9 billion according to the Senate and $96.4 billion according to the House. Interest savings from a lower national debt account for $30.3 billion.

House Budget Committee Chairman William H. Gray III (D-Pa.) said the budget was "not a perfect document . . . but a major effort" at deficit reduction.

Senate Budget Committee Chairman Pete V. Domenici (R-N.M.) called the budget "the best we could do under the circumstances." But he warned that the country faces deficits of at least $130 billion to $140 billion "forever" unless it raises taxes or cuts major benefit programs such as Social Security.

Under the plan, both defense spending and Social Security would be allowed to grow for inflation, but most domestic spending would be frozen or cut in what amounted to a split-the-difference compromise between the House and Senate.

However, the final compromise on domestic spending came after the Senate was forced by the White House to abandon $28 billion in cost-of-living savings from Social Security and other benefit programs. In the compromise, the House staved off roughly two-thirds of the domestic cuts the Senate originally sought.

But the House, which originally proposed a freeze in defense spending authority, had to accept the inflation increase proposed by the Senate.

The president succeeded in fending off major tax increases, including an oil-import fee. He also blocked earlier this week a delay in inflation adjustments for income-tax brackets proposed by the Senate. But he had to accept less for defense and more for domestic programs than he wanted. Reagan had wanted to increase military spending by 6 percent after accounting for inflation: $313 billion as opposed to the $302.5 billion level in the compromise budget.

And despite administration pressure for elimination of many nondefense programs, no major programs were scuttled except revenue sharing with local governments after next year.

Reflecting sensitivity to charges that the poor had borne an unduly heavy share of the burden of earlier spending cuts, the budget shielded programs for the poor and elderly, including food stamps, child nutrition and welfare, from new benefit cutbacks.

Both Medicare and Medicaid were cut, but in ways aimed at preventing additional costs to beneficiaries. Programs such as the Job Corps that Reagan wanted to eliminate were retained but scaled back.

But the budget put dents in programs that benefit the middle-class and wealthy as well as poor, ranging from mass transit and Amtrak to farm supports and business subsidies. Federal workers' pay would be frozen but not cut, as Reagan proposed.

Major savings were claimed from reducing the fill rate for the Strategic Petroleum Reserve and reaping a one-year harvest of receipts from oil and gas drilling on the Outer Continental Shelf.

But some of the more questionable savings claimed earlier by one or both of the houses, such as $4 billion from efficiencies in government contracting practices claimed by the House, were dropped. Also dropped were savings from user-fees for government loan programs that probably would never have been enacted.

Moreover, the House bowed to the Senate by agreeing to require more basic programmatic changes to achieve the long-term savings that were being claimed, presumably assuring that the savings will be made. Under a process called "reconciliation," the Senate had wanted to order $105 billion in program cuts, while the House wanted to order $36 billion in such cuts. They compromised on roughly $68 billion.

But there was still a strong undercurrent of doubt over whether many of the purported savings for fiscal 1987 and 1988 would ever be realized. Domenici, for instance, contended that deficits in each of those two years would be $25 billion to $40 billion higher than projected in the budget.

Nevertheless, much of the furor with which senators reacted to the White House decision to abandon Senate plans for Social Security constraints had subsided yesterday as most Republicans appeared to go along with Domenici's assessment that the compromise was "better than nothing."

Senate Majority Leader Robert J. Dole (R-Kan.) wavered earlier in the day about whether to bring the budget compromise to the Senate floor before the recess, holding a GOP caucus on the issue to test the water before going ahead with it. Participants described the session as "mellow" compared with earlier budget discussions and the consensus appeared to favor a grudging vote of approval for the budget.

But several senators called for a "veto strategy" by Reagan, coupled with further deficit-reduction efforts in connection with debt-ceiling extension legislation that must be enacted this fall.

The House also had last-minute problems when Rep. Neal Smith (D-Iowa) held up immediate consideration of the compromise package. He opposed the decision by House conferees to go along with the Senate in giving the Pentagon an inflation adjustment for next year.

Party leaders got around his objection with a parliamentary maneuver, assuring other restive lawmakers that defense spending could be curtailed further in appropriations measures that will be considered this fall.

The House also moved to kill the "imputed interest" provision of the 1984 Deficit Reduction Act. Members voted to repeal the law requiring sellers of real estate to charge prevailing interest rates on loans or pay a penalty to the IRS.

Imputed interest was included in the act to fight tax-shelter deals by making sure that transactions were taxed as if prevailing mortgage rates applied.

The House Appropriations Committee, meanwhile, sent the full House a $14.3 billion foreign aid bill weighted with assistance for Israel, Egypt and Pakistan. The panel, following quickly on Congress' approval of a separate 1986-87 aid authorization sent to the president Wednesday, passed on voice vote after Republicans lost on attempts to cut funds for export subsidies, the United Nations and the World Bank.

The end-of-the-year supplemental spending bill sent to Reagan yesterday contains $13 bi1lion for a variety of government programs, from Social Security to foreign aid.

From the administration's point of view, the key item is the renewal of the aid it sought for Nicaraguan rebels. But the bill provides that the money can be used only for nonmilitary purposes and bars the CIA and Defense Department from direct involvement with the program.

Reagan initially had sought military aid and had wanted the funds funneled through the CIA.

The bill also provides $1.5 billion in emergency economic assistance to Israel, $500 million to Egypt and $250 million to Jordan.

The bill contained about $48 million for 41 Army Corps of Engineer water projects. But the House and Senate yesterday agreed to freeze those funds until May 15, 1986 to allow both chambers to consider legislation that would force greater local cost-sharing of water projects.