The Carter administration, under pressure from major grain companies, announced yesterday that it will buy about $2.25 billion worth of grain that was to have been sold to the Soviet Union.

With Agriculture Secretary Bob Bergland at his side, Vice President Mondale said President Carter had ordered the unprecedented buy-up to support farm prices, which otherwise might have collapsed.

Carter announced last Friday that he was stopping sale of about 17 million tons of corn, wheat, soybeans and soybean oil and meal to the Soviets, in retaliation for their invasion of Afghanistan.

To prop up prices, Bergland said the next day the administration was considering paying farmers to keep grain they had not yet sold in storage, and off the market.

But that would not have helped the grain companies that had already bought grain for shipment to the Soviets.

The companies beseeched government officials over the weekend for help. The buy-out announced yesterday will, in large part, make them whole.

Officials said the Commodity Credit Corp. will pay 22 affected grain companies the same price the Russians had agreed to pay for the blocked grain. c

That will add enormously to U.S. grain reserves, which already were back about as high as when the Russians cleaned them out in their big grain purchases in 1972.

When markets reopen tomorrow -- the Commodity Futures Trading Commission closed them yesterday and today to give traders time to adjust -- prices are still expected to fall. But Bergland said yesterday the administration's program would mean "business as usual" for Amercian farmers within three months.

And Mondale said he believed a "vast majority" of the public -- including protesting farmers -- will support the president's decision to halt grain sales. "Farmers are Americans first, too," he said, mindful of the possible election-year consequences of Carter's act.

Both Mondale and Bergland said that yesterday's action, directing the Commodity Credit Corp. to buy up the grain, was necessary to "protect the farmers from loss" and to distribute any possible losses across the American economy.

They also suggested possible further aid to grain farmers if it proves necessary.

There were indications, however, that the Carter administration did not move toward the buy-up idea until it was besiezed by distraught grain traders over the weekend.

Representatives of nearly two dozen grain-exporting companies, who stood to lose millions if their sales to the Soviets were canceled, descended on Bergland Saturday and Sunday.

One result was the decision Sunday by the Commodity Futures Trading Commission to shut down all American grain exchanges for two days.

Representatives of at least 10 of the trading firms met with CFTC Chairman James Stone on Sunday to urge that the markets be closed to prevent prices from plummeting and leaving traders with huge losses.

And on the Canadian and European markets yesterday, grain prices dropped by the limit allowed under trading rules, reflecting uncertainty over U.S. export policy.

Before it came up with the federal agency buy-out, the administration had been predicting a $3 billion loss of farm income in 1980 as a result of the president's actions Friday.

Even with the federal purchases, some grain exporters stand to lose large amounts of money already paid to charter trains, barges and ships to get the grain to the Soviet Union.

Bergland pointedly noted yesterday that the agency buy-out does not include repayment of transportation costs. And, he added, the U.S. Department of Agriculture will assure that payments to the grain firms are passed on to farmers.

But farmers, who were not fully briefed on the Commodity Credit Corp. program until yesterday morning, still complained that the administration was catering to the exporters.

The chairman of the miltant American Agriculture Movement, corn and soybean grower Marvin Meek of Plainview, Tex. said the Carter plan "helps the grain companies . . . USDA needs to be sure it reaches all the way down to the farmer."

Agreeing for a change with the rival American Farm Bureau Federation, Meek said curtailment of grain sales to the Russians ultimately will hurt U.S. farmers -- even with the government purchases.

Other agricultural organizations complained that the Carter administration policy could permanently close the door to the Soviet market, which has purchased billions of dollars of U.S. farm products during the past decade.

Bergland hinted an additional aid to farmers, saying the administration is "looking at" the possibility of raising supports for farm products.

Meanwhile, in Des Moines yesterday, First Lady Rosalynn Carter, campaigning in advance of the crucial Jan. 21 Democratic precinct caucuses in Iowa, predicted that target prices will be raised.

The Commodity Credit Corp. plan calls for the government to buy 10 million metric tons of corn, 3.7 million tons of wheat, 740,000 tons of soybeans, 400,000 tons of soybean meal and 30,000 tons of soybean oil.

Purchases, made with borrowed funds, will be held in government storage until they can be sold without depressing prices, Mondale and Bergland promised.

If the corporation evenutally sells the commodities for less than it paid, deficits would be made up through general tax revenues. Bergland said that if the agency sold the grain at last Friday's closing prices, it would sustain a loss of about $260 million.

But other administration sources said the agency purchases are expected to add about $800 million to the fiscal 1981 federal deficit.

The administration does not need new congressional authority for yesterday's emergency action, Bergland aides said, but it would to raise basic price and income supports for grain farmers.

Grain traders, however, cautioned that prices generally will be pushed down as a result of the government's sudden stockpiling of about 650 million bushels of grain -- equivalent to roughly 13 percent of the country's annual farm exports.