The curse of American agriculture just two years ago - grain surpluses that were at near-record levels - may turn out to be the country's salvation as the disaster of the drought of 1988 unfolds.

With the Agriculture Department projecting at least a 31 percent reduction in U.S. output this year because of the drought, the stockpiles that bedevil farmers and policy makers have become increasingly vital to the food pipeline.Two years ago, the world had a 110-day supply of grain in the bins, the largest in 30 years. But that surplus depressed farmers' prices and created enormous storage and subsidy costs for the government. The United States, which accounts for about 15 percent of the world's grain supply and dominates the export trade, invoked crop-reduction programs.

The combination of these production cutbacks, plus drought here and in Canada and China, according to USDA analysts, will leave the world with a 63-day supply on hand next year, the lowest since the mid-1970s. That is tight, but not critical.

Despite evidence of further crop deterioration in the Midwest since USDA's Aug. 1 crop report, department officials remain convinced that U.S. grain supplies will meet most of next year's domestic and export needs. However, large amounts of oats and possibly some soybeans will have to be imported to meet shortfalls.

Several recent privately published reports, from the Worldwatch Institute and the League of Rural Voters, have suggested that the world will be entering a critical food-supply period in 1989, in part because of U.S. policies that have cut output and subsidized the sale of millions of tons of export grain to draw down stocks.

Worldwatch, for example, said total grain in storage would fall to about a 54-day supply because of the drought and government policy, or three days' less supply than was on hand in 1973 when grain prices doubled.

Ewen M. Wilson, assistant secretary of agriculture, and others at USDA dispute these analyses and dismiss comparisons between the current situation and the tight supply of 15 years ago.

"There is a big difference between now and the 1970s," Wilson said. "We are in a world in which demand is growing very slowly. Today, we are looking at a supply-induced shock (drought) that is reducing supplies. We're in a totally different environment than the 1970s."

In the 1970s, tight supplies were spurred by heavy demand. The Soviet Union entered the world market for the first time, making massive purchases. Third World countries were using easy foreign credit to make big food buys. The dollar was devalued, making U.S. grains more attractive.

A key difference today is that policy makers can quickly bring large amounts of U.S. farm land now idled back into production to help reduce the surpluses, much as one might open a spigot to get more water.

Agriculture Secretary Richard E. Lyng already has begun adjusting the spigot to bring more land into production next year to augment supplies.

The existence of the U.S. surplus stockpile, albeit less than half of what it was two years ago, has had another effect. It has precluded dramatic increases in consumer prices and, according to USDA, will continue to do so in 1989.

Although the drought has driven farm prices up, the department estimates that it will cause only an additional one percent rise in retail food costs. The earlier inflation forecast of 2-4 percent has been revised to 3-5 percent, with the cost of some products - red meat, chiefly - expected to drop because of huge shipments of livestock to slaughter due to high feed prices.

Another big drought in 1989, although regarded as statistically unlikely, is something that few officials at USDA want to contemplate. It could produce "catastrophic" consequences, in Wilson's words, because there would not be enough food to go around.