House and Senate negotiators neared agreement last night on legislation to revitalize the Gramm-Rudman-Hollings balanced-budget law by mandating automatic across-the-board spending cuts if Congress and the White House fail to meet annual deficit-reduction targets.

The tentative accord, which came after weeks of tortuous talks, would also delay the goal of a balanced federal budget by two years beyond the 1991 target set when Congress originally adopted the deficit-cutting law two years ago.

"I think we are going to have an agreement," House Ways and Means Committee Chairman Dan Rostenkowski (D-Ill.) said.

Senate Finance Committee Chairman Lloyd Bentsen (D-Tex.) said the negotiators had achieved a "major breakthrough" and that the conferees are "very optimistic" that the tentative agreement would be confirmed today. Sen. Phil Gramm (R-Tex.), one of the law's original sponsors and a key Republican in the talks, said "it looks like we're close to making a deal."

The amendment to Gramm-Rudman-Hollings, which will be attached to legislation raising the nation's borrowing ceiling that expires next week, is designed to meet the constitutional objections that doomed the law's original mechanism that automatically cut spending if Congress and the White House could not agree on how to reach that year's deficit target.

The Supreme Court struck down that provision last year.

Under the latest plan, Congress would have to reduce the deficit by $23 billion, to about $144 billion in fiscal 1988, which begins Oct. 1. Subsequent deficit goals would be $136 billion in fiscal 1989, $100 billion in fiscal 1990, $64 billion in fiscal 1991, $28 billion in fiscal 1992 and zero in fiscal 1993.

Revitalizing the balanced-budget law is expected to face difficulties in the House and Senate, where some liberal Democrats and conservative Republicans are expected to oppose it.

Repairing the budget-balancing law has been a key part of the Democratic leadership's strategy for forcing President Reagan into a compromise on the $1 trillion federal budget Congress adopted in late spring that called for a $19 billion tax increase. Those leaders believe that only the threat of across-the-board budget cuts that would slash military spending will force Reagan to back away from his repeated vows to veto a tax increase.

House Republicans, who during the Gramm-Rudman-Hollings talks have sought to shield the president from that choice, were less than enthusiastic about the tentative agreement reached yesterday.

"I think it's an interesting development and something may come out of it," said Rep. Bill Frenzel (R-Minn.).

House Republican members of the conference committee have said they could not support any revival of the budget law unless it contained provisions that would permit Reagan to veto individual components of the omnibus spending bills that Congress frequently uses to force the president to agree to its spending decisions -- of which there is little in yesterday's agreement.

But a Democratic leadership aide said that House Republicans will be "in a squeeze" if forced to vote against a budget law repair embraced by fiscally conservative Republican senators.