House-Senate negotiators last night stalled short of an agreement on legislation to force a balanced budget within five years, apparently hung up by a dispute over a proposed House compromise on domestic spending cutbacks to meet deficit-reduction targets.

One obstacle appeared to be objections from Sen. Phil Gramm (R-Tex.), principal sponsor of the bill, who said he saw a "real danger" in acceding to House demands for exemption of many low-income programs from prospective cutbacks.

Earlier, key Senate negotiators hailed a House proposal for limited cutbacks in health programs as providing the basis for settlement of the two-month-long dispute over the bill.

"It's a pretty good package . . . a pretty realistic package," Senate Budget Committee Chairman Pete V. Domenici (R-N.M.) said after he and Senate Finance Committee Chairman Bob Packwood (R-Ore.) emerged from a short bargaining session with House Majority Whip Thomas S. Foley (D-Wash.) and House Ways and Means Committee Chairman Dan Rostenkowski (D-Ill.).

Packwood and Foley also gave an upbeat assessment, predicting a final accord by today. They indicated other disputes involving the size of the cutback for this fiscal year and flexibility in cutting defense programs can be resolved once the domestic spending issue is settled.

But, after other Senate conferees gathered later to consider the offer, Domenici appeared less optimistic, and Gramm sharply criticized the House proposal.

Conferees from the two chambers met again behind closed doors to consider a Senate counterproposal and emerged after an hour, looking grim and without the usual claims of progress. Rostenkowski indicated there may be further moves today, but other conferees were noncommittal.

Under the House offer, Medicaid for the poor would be added to the list of programs exempt from cutbacks, which also includes Social Security and several antipoverty programs. Medicare for the elderly and other health programs would be subject to cuts of no more than 1 percent.

The legislation, passed in different form by the House and Senate, requires automatic across-the-board cuts in most programs if Congress fails to meet fixed targets for reduction of deficits from $200 billion to zero by fiscal 1991. It is part of a debt-ceiling extension bill that the Treasury Department says must be enacted by midnight Dec. 11 to prevent financial default by the U.S. government.

Meanwhile, the Senate Appropriations Committee approved its version of an omnibus spending bill for the government that President Reagan has threatened to veto if it exceeds congressional targets for domestic spending.

In both defense and domestic spending categories, the Senate proposal comes closer to meeting administration demands than a version of the bill that was narrowly approved Wednesday by the House despite veto threats from the White House.

While the House bill would freeze defense spending, the Senate proposal would allow an increase of about $10 billion to cover inflation. The Senate proposal would also spend somewhat less for domestic programs, although it appears to exceed administration benchmarks in several areas.

Differences between the Senate and House versions will have to be worked out by a conference committee after the Senate completes action on the measure, probably early next week. The Senate is scheduled to begin debate on it today.

The so-called continuing resolution is needed to fund government agencies that have not yet received their regular appropriations for the 1986 fiscal year that started Oct. 1. Congress has passed five of the 13 regular bills, and current stopgap funding runs out at midnight Dec. 12.

A House-Senate compromise on a sixth appropriations bill, providing $106 billion for the departments of Labor, Education, and Health and Human Services, was approved by the House yesterday and sent to the Senate.