Mexico has agreed to buy about a million tons of the U.S. grain that was to have gone to Russia, and it may buy more, U.S. officials announced yesterday.

The announcement came as Mexican natural gas began flowing across the border to this country after years of negotiation.

In part, "it's a matter of our sharing our abundance with them in hopes they will share their abundance with us," said Roger Krueger, the State Department's special coordinator for Mexican affairs.

President Carter threw U.S. grain markets into turmoil two weeks ago when he embargoed the planned sale of 17 million tons to the Soviet Union in retaliation for its invasion of Afghanistan.

The U.S. government later agreed to buy the grain to keep prices from plummeting. It plans to give some of the grain to needy countries; Pakistan has already been named as one. But the administration has been searching for other means of disposal, and Mexico, whose last harvest was poor, proved a ready market.

The agreement signed yesterday means Mexico will now buy about 7 million tons of U.S. farm products this year. That is about 1 million more than had earlier been expected and double the 3.5 million that Mexico bought last year.

The trade agreement signed yesterday calls for Mexico to purchase 4.8 million tons of farm products, in addition to about 2.2 million tons the Mexicans had already contracted for. About 1 million tons of the new purchases will be grain the Soviets had contracted to buy.The Department of Agriculture will work with grain companies to switch those sales to Mexico.

Mexican exports of natural gas to the United States resumed Tuesday after a long delay caused by a dispute about price.

The day that gas sales resumed, Mexican Secretary of Commerce Jorge de la Vega arrived in Washington for grain talks and an agreement was reached within 48 hours, U.S. officials said.

Mexico is stepping up grain purchases because a drought and early frost severely reduced its harvest this year, de la Vega said.

The increased grain sales will be handled through normal commercial channels with no special credit terms or price breaks, U.S. officials said.

The United States is negotiating with other countries to dispose of more of the grain from cancellation of the Soviet deal, said Dale Hathaway, undersecretary of agriculture for international affairs.

U.S. grain reserves now are approaching their highest levels since the 1960s because last year's harvest was bigger than previously reported, the Agriculture Department disclosed earlier in the day.

Raising its earlier estimate of the nation's corn corp by 178 million bushels, Agriculture said the 1979 crop was a record 7.76 billion bushels.

The unexpectedly large crop added to the government's problem of disposing of the Russian grain without depressing farm prices.

The new crop report alone will cause corn prices to fall by 5 to 10 cents a bushel, predicted Howard Hjort, the Agriculture Department's chief economist.

The Carter administration has promised farmers that grain prices this year will be no lower than they would have been if the huge sale to the Soviets had been completed.

Hjort said the new crop report and the loss of Soviet business increases the likelihood the administration will establish new programs to limit farm production this year.

"The odds are greater than they were yesterday" that farmers will be paid not to grow crops, he said.

In a speech in Atlanta, Secretary of Agriculture Bob Bergland said the United States is prepared to end grain trade with the Soviets for the foreseeable future. "We can write the Russians off permanently. The prices won't be affected at all," said Bergland.

The 4.8 million-ton grain deal signed yesterday calls for Mexico to spend about $750 million on U.S. farm products this year. Mexico's main purchases will be 1.7 million tons of corn, a million tons of sorghum, 650,000 tons of wheat and 500,000 tons of soybeans.