Senate negotiators yesterday reached an agreement on a measure that would require automatic, across-the-board spending cuts if Congress and the White House fail to meet their deficit targets.

The agreement on the automatic mechanism, designed to pass constitutional muster, also will enable legislators to pass a long-term extension in the federal borrowing ceiling.

The budget law and the debt ceiling have been bound together as part of a Democratic attempt to force President Reagan to accede to a $19.3 billion tax increase that is key to the Democrats' plan to reduce the deficit.

Earlier yesterday, Congress averted a government financial crisis by passing a one-week extension of the federal debt limit that will permit the government to continue to borrow to pay its bills and pay off maturing securities.

Had Congress failed to extend the debt ceiling by Friday, there would have been an unprecedented U.S. default on its securities, because the Treasury would have run out of cash to pay maturing obligations and would have been unable to borrow to do so.

But yesterday afternoon the House approved, 263 to 155, legislation extending the $2.3 trillion debt ceiling to Aug. 6. The Senate then approved the measure on a voice vote.

Meanwhile, Republican and Democratic negotiators in the Senate announced an agreement on an amendment to a long-term extension of the debt ceiling that would add a new automatic spending-cut mechanism to the 1985 Gramm-Rudman-Hollings balanced budget law. That compromise, which also includes a relaxation of annual deficit goals that now are widely viewed as unachievable, is expected to be taken up by the Senate today.

The Supreme Court struck down the original budget-cutting provision last year.

Sen. Pete V. Domenici (R-N.M.), the ranking Republican on the budget committee, said the compromise would "bring the deficit under control."

Under the compromise -- worked out between Senate Budget Committee Chairman Lawton Chiles (D-Fla.) and Domenici and Sen. Phil Gramm (R-Tex.) -- Congress and the White House would have to achieve a deficit of $150 billion in fiscal 1988, which begins Oct. 1. They are supposed to reach $130 billion in fiscal 1989, but the goal is not rigid.

In subsequent years, there would be a return to fixed targets: $90 billion in fiscal 1990, $45 billion in fiscal 1991 and a balanced budget in fiscal 1992. Gramm-Rudman-Hollings originally called for a balanced federal budget by fiscal 1991.

The compromise also includes a mechanism under which the White House could have some flexibility in choosing which defense programs to cut, but would have to submit a plan for congressional approval.

Under the original Gramm-Rudman-Hollings law and the proposed amendment, the across-the-board reductions would be equally apportioned among defense and domestic programs.

The agreement also gives the Office of Management and Budget more authority than Democrats originally wanted in triggering the cuts, but calls for a congressional review in the first year if Congress objects to OMB's guidelines.

Democratic leaders view a reinvigorated Gramm-Rudman-Hollings law as the centerpiece of their efforts to get President Reagan to accept the $19.3 billion tax increase contained in their $1 trillion budget for fiscal 1988.

With the Gramm-Rudman-Hollings fix in place, Reagan would have to choose between abandoning his vow to veto the tax increase or bowing to deep defense cuts. That prospect has caused the administration to retreat from its commitment to a restoration of the law's budget-cutting teeth. But Domenici said yesterday he expects the compromise to be acceptable to the White House.