A mulish and unhappy Senate gave the administration another victory yesterday, passing a new and scaled-down farm bill after a tumultuous week that saw old coalitions collapse under extraordinary budget pressures.

The bill, closely tailored to White House fiscal demands, would establish farm commodity support levels and direct rural development policy for the next four years.

Final passage came by the unusually close vote of 49 to 32, a reflection of the week's divisions and lingering discontent. Both Virginia senators voted aye, both Maryland senators no. It was the first time in memory that a farm bill had been so pummeled before passage in either house.

Precise cost estimates were not available, but the bill was said by Senate aides to have been brought back within several hundred million dollars of President Reagan's demands--close enough to be acceptable, Agriculture Secretary John R. Block said.

Block said he was pleased by the bill and would urge the House to follow the Senate's austerity course.

"Most farmers' concerns are focused on high interest and low farm prices," Block said. "Most feel this bill won't provide high prices--it's not supposed to do that--and farmers don't look to the bill to do that."

The week's floor battles, which saw Agriculture Committee members turning against each other and their chairman, Jesse Helms (R-N.C.), symbolized the painful change forced by the president's budgetary hard line.

The dairy industry, plotting until the end to derail the bill, was hit hardest. The Senate rejected its committee recommendation and moved to cut dairy price supports to the much lower level Reagan sought to reduce federal purchases of surplus milk. Even at that, next year's outlays are expected to exceed $1 billion.

The sugar industry won approval of a new price support program that is virtually certain to raise consumer costs, but saw the support level reduced from the committee version.

Target prices--points below which the government moves to shore up the income of farmers directly--were slashed for grain and cotton farmers to the level sought by the administration, although it was not able to eliminate the subsidies as it had first urged.

Southern farmers and acreage allotment holders saw their exclusive control over peanut production substantially weakened after an assault on "special interests" mounted by Sen. Richard G. Lugar (R-Ind.).

The only real survivor of this unprecedented chain of commodity-by-commodity muggings was tobacco, which narrowly escaped attempts to alter the price-support and acreage allotment system that has kept it prosperous.

Survival was not without its costs, however; the southern tobacco legislators' dogged defense of their program left other senators antagonistic, and typified the breakup of the once-solid farm front.

At one point during debate, after grain-state senators helped tobacco win a key roll call by three votes, Sen. J. James Exon (D-Neb.) put the burley and flue-cured backers on notice.

"Tobacco had better look around and see from whence came those key votes," he said, unsuccessfully pleading for adoption of an amendment that would have set target prices back at levels originally approved by the committee.

Lugar, a member of the farm committee, played a leading role in forcing the Senate's hand. His meat-ax approach to peanuts and target prices--he proposed killing both programs--helped set the tone of budget frugality.

"The president was the catalyst for this," Lugar said, "but this has been a healthy process. The Senate came much more alive to study the issues, and some of these votes took a considerable amount of political courage."

He added, "It is a very different ball game now. Our committee in markup proceeded down its old ways--it looked like the old style--and by the time our bill hit the floor, Secretary Block said it was $1.5 billion over budget . . . that had to be remedied if the president's budget campaign was going to have any credibility."

A major confrontation occurred yesterday over target prices, spurred by Lugar's proposal to wipe out the program.

Part of the dilemma the Senate found itself in this week stemmed from target price payouts. As recently as March the Department of Agriculture was anticipating no payments of the subsidies to farmers.

But then, as it became clear that there would be a record wheat crop and an unexpected $500 million in target price costs, near-panic set in.

The result was a new administration effort to drive down potential costs of the farm bill. Committee caucuses last week achieved much of that, but left members bitterly divided and resentful toward White House arm-twisting. On a narrow vote yesterday the Senate went along with a compromise to the Lugar proposal and dropped target prices to levels acceptable to Block.

The House will now be under pressure to move its version of the bill so final action can occur by Oct. 1, when current farm programs expire.