Farm legislators, belying a reputation as master finaglers able to wriggle out of any financial bind, have agreed to chop $13.6 billion from agricultural spending over the next five years.

The agreement, worked out in a four-hour, Senate-House closed caucus Friday night, brought farm spending in line with requirements of the budget bill passed by Congress last week. Congress stipulated $13.6 billion as agriculture's share of a budget-cutting plan designed to save $500 billion over the next five years.

The caucus was part of a legislative frenzy late Friday and early yesterday in which lawmakers shuttled among several committees and offices seeking ways to cut spending and generate new tax revenue.

Early Saturday, the tax-writing Senate Finance Committee passed a bipartisan deficit-cutting plan that would raise the gasoline tax from 9 cents to 18 1/2 cents per gallon, limit income tax deductions for taxpayers earning more than $100,000 per year and take a bigger bite out of payroll taxes to fund Medicare. In all, Medicare would be cut by $49 billion, with most of the cost borne by health-care providers, although the annual deductible paid by recipients would double from $75 to $150.

The plan, which would raise $142 billion in taxes and cut $42 billion in spending over five years, is likely to be more acceptable to President Bush than earlier tax proposals; it doubles "the share of the tax burden on those making over $200,000 per year and {reduces} the burden on the vast majority of American families," said Senate Finance Committee Chairman Lloyd Bentsen (D-Tex.).

Less fortunate was the foreign aid bill, where the Senate reached an impasse and adjourned after Republicans objected to a plan by Sen. Timothy E. Wirth (D-Colo.) to offer an amendment overturning long-standing policy requiring that U.S. population aid go only to private organizations that do not promote or practice abortion. Senate Majority Leader George J. Mitchell (D-Maine) said the deadlock marked "a significant step backward" in the Senate's effort to recess by Oct. 19.

For farm legislators, Friday's session may change their enduring reputation as clever wheeler-dealers capable of squeezing dollars for their states from a vast array of arcanely crafted programs that only they understand.

Agriculture Secretary Clayton Yeutter, a frequent critic of the farm committees' propensity to spend lavishly, emerged from the four-hour meeting to endorse the new agreement as "a solid package.

"None of us is totally satisfied, but in my judgment we've done about as well as could be expected with such enormously difficult issues," Yeutter said. "The conferees made a diligent, good-faith effort to make real savings."

Senate Agriculture Committee Chairman Patrick J. Leahy (D-Vt.), who hosted Friday's caucus in a meeting room next to the Senate chamber, acknowledged he "was not happy with the news" that drastic cuts were going to be made in farm programs, but "I can tell our farmers that they will be treated fairly."

Details of the farm-spending cuts were being worked out by the Senate and House agriculture committees in staff meetings this weekend. The final figures will be incorporated into the new five-year farm bill being negotiated by the committees concurrently with the budget agreement.

Fair or not, the new farm-spending provisions are destined for a grim reception. Nearly $9 billion of the $13.6 billion will come from reductions in government subsidies and in the acreage eligible for subsidies. The plan will hit hardest among grain farmers who for decades have received artificially high subsidy payments for a large portion of their crops.

Under the congressional budget plan, only $1 billion needs to be cut from farm spending in 1991, a goal that can be reached simply by retooling existing programs. Beginning in 1992, however, the plan will reduce payment acreage by 15 percent, a drastic change that could fundamentally restructure the farm subsidy system. The $13.6 billion represents a 25 percent cut in estimated farm spending over the next five years.

For this reason alone, the 1990 farm bill, which will regulate U.S. agriculture for those five years, figures to be a historic document. House and Senate conferees are expected to finish writing it this week.

The bill also is noteworthy for several ambitious environmental provisions covering everything from conservation practices to the use of pesticides, herbicides and fertilizer.

One provision regulating the export of dangerous chemicals -- the so-called "circle of poison" -- figures to be a sticking point in the Senate-House conference.

The Senate version of the bill sharply restricts such exports; the House version is slightly more lenient. Recently, however, the Senate Agriculture Committee's ranking Republican, Sen. Richard G. Lugar (Ind.), proposed an amendment that would allow export of most chemicals as long as importing countries are willing to receive them.

Environmentalists have attacked the Lugar amendment for "gutting circle of poison." Lugar, whose position is supported by the Bush administration, said it would be "shortsighted" to "arbitrarily cut off an export market."

Staff writers Helen Dewar, Tom Kenworthy and Dan Morgan contributed to this report.