President Reagan made a pre-election gesture to struggling American grain farmers yesterday by opening the door for the Soviet Union to buy up to 23 million metric tons of U.S. wheat and corn and promising that purchases made soon would not be affected by any future grain embargo.

Reagan guaranteed that, even if he decided it was necessary to impose a new grain embargo against the Soviet Union in response to actions taken in Poland or elsewhere, it would not affect grain purchased during November and shipped within 180 days except in "extreme circumstances."

In a morning radio broadcast from Washington through station WHO in Des Moines to 12 farm-belt states, the president said there was no certainty that the Soviets would purchase the grain, "but we know they're shopping and they still have large needs."

The announcement was significant for hard-pressed American farmers because it offers the Soviets a further inducement to purchase additional U.S. wheat and corn at a time of rock-bottom prices and depressed farm income in the Midwest.

Capping a week of presidential activities aimed at shoring up support before the Nov. 2 congressional elections, Reagan's 10-minute speech to farmers set the stage for his two-day campaign swing next week into the heartland battlegrounds of Nebraska and Illinois.

But the grain announcement also put Reagan in the position of insisting on sanctions against European sales of American technology for the Soviet natural gas pipeline -- because of repression in Poland and Afghanistan -- at the same time that he is encouraging ever-larger exports of American grain to the Russians. Just a week ago, the president announced that he was lifting favored-nation trade status from Poland and considering other sanctions to protest the outlawing of the independent trade union Solidarity by the Soviet-backed military regime there.

Anticipating criticism that his actions are sending contradictory messages to Moscow, he said yesterday it is "wrong" to assume the United States is sending a "weak signal" by opening the granary doors of American farms to the Soviets.

"We're asking the Soviets to give us cash on the line for the food they buy," Reagan said, making a distinction he has previously cited to reconcile the grain sales and high-technology embargo. "We're not providing them with any subsidies or pumping any western currencies into Soviet pockets.

"It's always seemed ironic to me that many people who are so quick to sacrifice the interest of farmers in an effort to seem tough are unwilling to do the real things we need to send a signal of national will and strength," Reagan said. Those "real things" include a military buildup to match the Soviets, he added. "We have our priorities straight."

The president's decision, as expected, was criticized in France and West Germany yesterday as setting a double standard for trade with Moscow. But Agriculture Secretary John R. Block told reporters here that "I don't have any sympathy" for the complaints. He said the Europeans are just "blowing smoke."

American farmers have been squeezed financially this year with another bumper crop on top of last year's robust harvest, while grain prices have hit bottom and exports lagged. This has produced political restiveness in the Midwest this autumn, a potential threat to Republican candidates for Congress and the statehouses.

Ever since President Carter's Jan. 4, 1980, embargo on grain sales to the Soviet Union to protest the Soviet invasion of Afghanistan, American farmers have charged that the United States lost credibility in world markets as a reliable supplier of grain.

They have urged Reagan to pledge unconditional guarantees or "sanctity" against disruption for grain contracts to help rebuild the diminished U.S. share of Soviet grain imports. Farm-belt congressmen have introduced bills this year to force the administration to offer guarantees against embargoes.

Reagan promised a limited guarantee yesterday. Describing the Carter grain embargo as "mistaken," the president vowed, "We will honor our word."

The formal U.S. grain offer will be made Oct. 28-29 at a meeting with Soviet officials in Vienna. The two nations are now operating under a long-term grain agreement that has been in effect since October, 1976, and extended on a yearly basis.

The current year's agreement, which began Oct. 1, calls for the Soviets to purchase a minimum of 6 million to 8 million metric tons of corn and wheat. Yesterday, Reagan authorized them to purchase another 15 million metric tons.

This 23-million-ton total is the same amount of grain the Soviets were allowed to purchase last year. Total Soviet imports of grain were about 40 million metric tons, but they relied heavily last year on supplies from Canada, Australia and Argentina, among other nations. From the United States last year, the Soviets bought a total of only about 13.9 million metric tons.

Reagan is making the same 23-million-metric-ton offer this year but with one twist. Under terms of the existing agreement with the Soviets, the first 8 million metric tons are guaranteed against disruption. The president said he will make such a guarantee for all 23 million metric tons against disruption if the Soviets buy the grain during November and ship it within 180 days.

White House officials said the guarantee, written into the Soviet-U.S. agreement, was not "absolute." But they pointed out that it was not broken during the Carter embargo when the promised 8 million metric tons were sold, despite the cancellation of 17 million metric tons in additional sales. Reagan said the guarantee would apply to soybeans and other commodities the Soviets might purchase next month as well.

Administration officials were uncertain whether the Soviets would be willing to make such large purchases within the November deadline.

But Michael Hall, a spokesman for the National Corn Growers Association, said he believed the administration would extend the deadline if it appears the Soviets are interested in large purchases. White House officials would not commit themselves to an extension.

Hall outlined several reasons why the Soviets might increase purchases of U.S. grain this year. He said a drought has severely limited the export supply of wheat from Australia, previously a large supplier. Also, the restructuring of Argentine currency following the Falkland Islands war could restrict Moscow's purchases from that nation, he said.

Other traditional Soviet sources of supply, such as Canada, have already made commitments for most of their crop at a time when deteriorating Soviet harvests and bulging livestock herds have placed new demands on Moscow to import grain, he added.

Hall said Reagan's action would remove some of the "uncertainty" hanging over the United States as a world grain supplier.

Since the current year began Oct. 1, the Soviets have purchased 1.6 million metric tons of corn and no wheat. Block said yesterday he would stick by his earlier prediction that the Soviets would buy between 18 million and 20 million metric tons in 1982-83.