The Senate yesterday gave its final approval to the multi-billion-dollar farm bill, but the 49-to-41 margin was too thin to override a promised presidential veto if the legislation survives its House test later this week.

The Senate vote in favor of higher farm price supports came as President Carter prepared to make a speech today outlining a new anti-inflation plan for restraining prices in general . (Details, A3). The president opposes the farm bill.

"We've ruined any chance of helping farmers by being excessive," said Dick Clark (D-Iowa) as the Senate rode over opposition from the administration and leaders of both parties to support a bill that would help only wheat, corn and cotton farmers and would, according to the Congressional Budget Office, add 2 1/2 percent to the retail cost of food this year.

Edmund S. Muskie (D-Maine), whose Senate Budge Committee is now writing the first budget resolution setting tentative spending ceilings for next year, said bills like the farm measure "undermine my faith in the ability of Congress to act responsibility on tax and spending legislation." Henry Bellmon (Okla.), senior Republican on the Budget Committee, said he feared the vote "will signal a return to the old free-spending days in the past."

The Senate was responding to pressures from farmers who have been in Washington since the first of the year demanding additional government action to raise prices which they contend are below production costs. The Senate visitors galleries were filled with farmers yesterday as have been the committee rooms during the bill's progress through House, Senate and House-Senate conference.

"In a headlong rush to respond to the strident voices of one segment of our farm population," said Muskie. Congress has ignored the impact on livestock, poultry and dairy farmers of the higher feedgrain prices resulting from the measure.

The bill, authored by Republicans, would raised the level of price supports in direct proportion to the amount of land a farmer took out of production. In he set aside one third of his wheat land, the target price that the government would guarantee for a bushel of wheat would increase from $3 to $5.04. The administration has agreed only to raise the target price of wheat of $3.40 a bushel.

The Congressional Budget Office said five percent of the nation's farmers would get one-third of the benefits from the bill. Last year that group of farmers receive net income of about $50,000 each; said Muskie, who contended that little farmers would get little help from the bill and have been sold a "phony bill of goods."

Muskie said some farmers have been caught in a cost-price squeeze because they overextended in land equipment during the early 1970s when grain prices were abnormally high. He said farm income is now rising under the 1977 Farm Act and Congress should not act hastily to "bail out every small and large businessman who makes an unsound investment."

Clark acknowledged a need to help grain farmers who are selling below cost, but he said the approach should be more modest. He cited the effort by House Agriculture Committee Chairman Thomas Foley (D-Wash.) in the conference to raise the wheat target price to $3.50. Framers in the gallery laughed at that, were gaveled into silence by the presiding officer.

Bob Dole (R-Kan.), principal author of the bill, insisted consumer costs would be less than the budget office predicted and said: "Don't punish the American farmer just because the bill has a Republican name on it."

The Senate voted 49 to 43 to waive the Budget Act prohibition against authorizing spending for next year before the first budget resolution has been adopted, and then approved the conference report, 49 to 41.

All Maryland and Virginia senators voted against the waiver and the bill.

On the key vote to waive the Budget Act, Democrats divided evenly 29 and 29, while Republicans voted 20 to 14 to waive the spending prohibition.

Lask week House Democratic leaders considered a strategy of waiving the Budget Act, trying to kill the conference report and, if that succeeded, immediately taking a vote on Foley's more modest bill. They sought to protect President Carter from the embarrassment of a veto.

But the White House, according to one of its congressional workers, isn't interested in receiving a middle-sized farm bill. It wants the House either to kill the package approved by the Senate yesterday or send it to the president so that he can veto it as inflationary. Foley said he wouldn't try a compromise approach unless the administration approved.

Congress can force a bill into law over a veto only by a two-thirds vote of both House and Senate.