The 98th Congress hit a major snag early today as it struggled toward a belated adjournment after giving final approval to a $370 billion, long-overdue spending bill for much of the government that was stripped down to prevent a veto by President Reagan.

As the Senate was about to pass a debt-limit extension that also must be approved before adjournment to keep the government from running out of credit, Democrats moved to block passage in an attempt to flush out Republican votes for it.

In a last-minute scramble of vote changes, the debt measure was rejected, 46 to 14, and Majority Leader Howard H. Baker Jr. (R-Tenn.) recessed the Senate until 11 a.m. today.

The debt bill, hung up earlier in an unrelated Senate fight over taxation of seller-financed real-estate deals, would raise the government's borrowing ceiling to $1.824 trillion. The government reached the current ceiling of $1.573 trillion Wednesday, and some securities sales have been delayed.

A compromise on the tax measure, calling for a six-month delay in imposition of the new rules, was finally worked out shortly before midnight and passed by both chambers.

After the surprise debt bill vote, Baker said that he expects to have enough Republicans on hand today and that some will switch votes and others, who had left town, will return and support the measure.

A Republican aide said the White House has indicated that it will cooperate in providing Air Force transportation to collect senators to return for the vote.

Baker noted that Democrats usually withhold support for debt ceiling measures in order to force Republicans, who often campaign against Democrats on the debt issue, to vote in favor of increasing the debt.

"There's always a level of brinksmanship . . . this time we fell off the edge of the bluff," Baker said in exasperation just after being honored by members of both parties on his impending retirement from the Senate.

A Republican leadership aide said Congress could be in deep trouble on the debt issue if it does not resolve the impasse by midnight today because, under an adjournment resolution passed by both chambers, the 98th Congress expires at that time. The aide said one recourse might be to have Reagan call Congress back for a special session.

Among Democrats, only Russell B. Long (D-La.) voted for the debt extension. Thirteen Republicans voted in favor and 18 against.

Earlier, amid what Sen. David F. Durenberger (R-Minn.) called the loud "rustle of airline tickets" mong the homeward-bound lawmakers, there were these other developments:

*Congress officially abandoned hope of passing landmark immigration revision legislation that would have granted legal status to millions of illegal immigrants. Although the bill had survived several potentially lethal blows, the bill finally got trampled in the rush for adjournment, the target of opposition from unions, growers and Hispanics, half-hearted support from the administration and whole-hearted opposition from the Democratic national ticket. Other measures that did not survive the end of the session were civil rights and "Superfund" toxic-waste cleanup bills.

*Congress enacted legislation authorizing about $9 billion in spending this year for the CIA and other intelligence agencies. Although the figures were classified, sources said the total represents an increase of 20 to 25 percent over current spending. The sources said the administration's request had been cut by 8 to 10 percent.

*The Senate, voting 87 to 2, endorsed principles of a 35-year-old treaty outlawing genocide after putting off ratification until next year because of filibuster threats by conservative opponents.

*The Senate gave final approval by voice vote to a bill guaranteeing Social Security recipients a cost-of-living increase in January, even if the rate of inflation is insufficient to trigger the increase automatically.

*The House approved and sent to Reagan a bill that sets federal standards for municipal regulation of cable television.

*The House insisted on banning U.S. loans to the South African government as part of legislation to curtail export of strategic goods for foreign policy reasons, and the Senate, which opposes the South African restriction, did not pass it.

*Congress voted to give municipalities protection from liability for damages in antitrust suits, partially closing a legal avenue opened by a 1982 Supreme Court decision allowing hundreds of suits against cities.

As the members headed home, they could look back on a two-year Congress that began with passage of major Social Security financing reforms and a huge anti-recession jobs program and ended with an ignominious financing snarl in which Congress almost let the government run out of borrowing and spending authority at the same time.

Between the start and finish, Congress enacted a deficit-reduction "down payment" of nearly $150 billion in spending cuts and tax increases over three fiscal years, cut back somewhat on Reagan's proposed military buildup and put varying degrees of restraint on foreign policy ventures, ranging from troop deployment in Lebanon to covert antigovernment activity in Nicaragua.

It made Martin Luther King Jr.'s birthday a national holiday and strengthened the Voting Rights Act but refused to reverse a Supreme Court decision narrowing the scope of federal antidiscrimination laws. It passed major wilderness legislation but stalled over expansion of the Superfund for cleanup of toxic waste. It passed major anticrime legislation but balked at most other favorite causes of the New Right.

In all, it bucked most contentious issues over to the 99th Congress, which officially convenes on Jan. 3 although it will not begin serious business until later that month.

Final passage of the roughly $370 billion catchall spending bill called a continuing resolution occurred at midday when the Senate approved it by 78 to 11. The House voted 252 to 60 to approve the measure late Wednesday.

As the Senate vote neared, Baker told his colleagues he had been authorized to say "the president will approve this measure."

Earlier White House veto threats had prompted House Democratic leaders and later House-Senate conferees, after some stalling and grumbling, to drop about $100 million in dams, ports and other water projects that had raised administration objections.

In return, the administration agreed reluctantly to go along with a ban of at least five months on aid to anti-government Nicaraguan rebels under conditions that make it unlikely that the moratorium would be lifted.

The measure also includes a major anticrime package that Reagan had wanted, although it does not go as far as he originally proposed.

Passage of the continuing resolution came only a day before the government faced the possibility of another partial shutdown, similar to he half-day layoff caused by an earlier expiration of funding authority last week. Existing spending authority for many agencies, ranging from the Pentagon to the Labor Department, expired at 12:01 a.m. today.

The continuing resolution was drafted to finance most government agencies, including the Defense Department, for a full fiscal year.

The money was wrapped together in one bill because Congress, bogged down in budget disputes, had not been able to pass separate appropriations bills for each department and agency by Oct. 1, the start of the 1985 fiscal year.

Usually such catchall measures are for a shorter period or include full-year funding for a smaller number of agencies, but there has been a gradually developing trend toward omnibus spending bills, largely because of budget-related delays in Congress.

Virtually every piece of unfinished business from the 98th Congress became a potential amendment to the spending bill, familiarly referred to as "the last train out of the station" for campaign-related legislative goodies.

The final package arrived in the Senate weighing about 10 pounds and standing nearly six inches high. Many lawmakers suggested privately it was a monument to how not to run a government.

Both chambers were filled with recriminations as the measure was approved just a few hours before the affected agencies were to run out of stopgap funding for a fifth time in less than two weeks. At one point, Rep. Silvio O. Conte (R-Mass.) pointed to a stack of Senate amendments to the measure and called it "173 pages of primal urge."

The continuing resolution includes about two-thirds of the funds needed to operate the government through Sept. 30, 1985. It covers the departments of Defense, Agriculture, Interior, Treasury and Transportation as well as the foreign aid program and large independent agencies such as the Office of Personnel Management, the U.S. Postal Service and the General Services Administration.

The Defense Department section of the bill reflects an earlier agreement by House and Senate leaders to raise military spending by about $40 billion in fiscal 1985, an after-inflation increase of about 5 percent. Reagan had requested 13 percent, then lowered it to about 8 percent in an agreement with Senate Republicans.

The measure puts off until early spring two critical decisions: whether to allow further production of MX missiles and whether to permit a resumption of military assistance to antigovernment "contra" forces in Nicaragua. In both cases, either house of Congress has what amounts to a veto, giving the upper hand to foes of the MX and the contra aid program.

The military portion of the resolution delays space testing of antisatellite weapons until March and expresses a sense of the Congress that no U.S. combat troops be deployed in Central America. The request for $1.6 billion to plan a new "Star Wars" defense system in space was cut to $1.4 billion, but proposed restrictions on deployment of nuclear-tipped, sea-launched cruise missiles were dropped.

The overall bill, along with the companion labor, education and health appropriations measure, continues a pattern of restoring some funds that were cut earlier in Reagan's term from major social welfare programs, principally education, health and nutrition.

For instance, there were major increases in the Pell grant program for low-income college students, substantial increases in education and health spending and a modest increase in food stamp allotments.

But there were cuts as well. The final agreement reduced spending authority for the Synthetic Fuels Corp. by $5.4 billion, less than originally requested, and trimmed $300 million from the strategic oil reserve.

A foreign aid program of $18.2 billion includes an increase of more than $600 million, although Reagan's request for military aid was cut. The program embodies nearly all of what the president wanted in military and economic assistance to El Salvador but reflects a cut from what he requested for Turkey.