Saudi Arabia, fighting both the persistent global oil glut and its rivals in the Organization of Petroleum Exporting Countries, is waging a long and costly battle to prop up world oil prices.

The Saudis have slashed their crude oil production this year to its lowest level in a decade to bolster the price, and their revenues dropped $40 billion from last year as a result. They acted to stave off a collapse that could have pulled down U.S. gasoline prices to less than $1 a gallon.

In the maneuvering before a meeting of OPEC oil ministers that begins in Vienna Sunday, the Saudis had dropped a few hints that they might have to cut prices despite their effort. The glut has lasted longer than expected, and some OPEC members continue to cheat on the organization's pricing and production agreements.

Recently, however, the Saudis have vowed to continue supporting prices. U.S. analysts in government and industry believe that prices will remain roughly stable at least until spring, when reductions might become necessary if demand for oil falls sharply at the end of the winter heating season.

World oil markets have turned topsy-turvy since the middle of last year. At that time, the Saudis were pumping oil at a record level to keep prices from rising. The Saudis' action encouraged the United States to sell the kingdom advanced radar reconnaissance planes.

Today Iran and Libya, among the bitterest foes of U.S. policy in the Middle East, are the ones giving consumers a break. Confident that Saudi Arabia will sacrifice to shore up the market, they are undercutting Saudi prices, encroaching on the Saudi market share and boosting their own sales and revenues. Venezuela and Nigeria also have raised their output while the Saudis were cutting back.

At the OPEC meeting, Saudi Oil Minister Ahmed Zaki Yamani is expected to pressure his competitors to help him uphold the organization's official price of $34 a barrel by cutting their production and eliminating price discounts.

The Saudis and a handful of allies, including Kuwait and the United Arab Emirates, have indicated that they will seek to revive an OPEC agreement setting production limits for individual members.

The accord was adopted in March amid much fanfare as the first formal production-sharing deal in OPEC's 22-year history. It effectively expired in July, however, when OPEC could not agree on how to deal with members that were exceeding their limits.

All OPEC members now are saying that prices must be prevented from falling, but the Saudis' competitors appear unlikely to compromise on how to share the sacrifice involved. Iran already has asked for a new production ceiling of 3 million barrels a day, compared to its old ceiling of 1.2 million and current production estimated at 2.5 million to 2.7 million.

As a result, Saudi Arabia is likely to continue to bear the brunt of fighting the glut. Essentially it is paying the cost of being the world's largest oil exporter in a weak market, analysts say. Smaller producers can offer discounts to attract buyers without causing a stampede, but prices would plunge if the Saudis joined in a price war.

"They have more to lose than gain from a general decline in prices. Revenues for everybody would fall," said a senior Middle East analyst for a major U.S. oil company.

In the summer of 1981, the Saudis were pumping 10 million barrels a day to prevent prices from rising. As the world recession cut into oil demand, however, the glut began to get out of hand. The kingdom began cutting production to reduce the oversupply, and this year its output has fallen 35 percent to less than 6 million barrels a day.

So far the Saudis' efforts have paid off. The fall in the average price of OPEC oil was held to 60 cents a barrel this year, or less than 2 percent, according to Energy Department figures. In real terms, or after adjustment for inflation, OPEC prices have dropped 16 percent since they peaked two years ago.

The question is how long the Saudis are willing to accept low production levels before concluding that the market is too weak to sustain current prices.

OPEC and oil industry analysts alike had expected demand to rise substantially this winter, but the economic slump has lasted longer than forecast, and relief has been minimal.

Middle-level managers in the Saudi state-owned oil company Petromin would like a price cut to draw back buyers who have flocked to Iran, Libya and other OPEC members offering cheaper crude, according to petroleum industry sources.

Saudi officials including Yamani have been quoted over the past two months as saying that they were willing to consider a price reduction. A cut also was urged by a prestigious research panel that included members considered close to the Saudis.

The Saudis quickly backed off from these veiled threats to launch a price war, however. Both Yamani and King Fahd were quoted by the Saudi press as saying that they were committed to uphold the $34 per barrel OPEC price.

The kingdom may have dropped the hints to scare its competitors into raising prices a bit, but Iran was not intimidated and accused the Saudis of bluffing. The Iranians are selling their oil for about $28 to $29 a barrel, while the Libyans have offered discounts in refining deals.

"It's a game of chicken, a question of who is willing to tough it out the longest," said G. Henry Schuler, director of energy programs at Georgetown University's Center for Strategic and International Studies.

Analysts suggest that the Saudis and others might offer some under-the-table discounts of their own, perhaps by allowing easier credit terms to buyers. Some industry sources believe that the Saudis would reduce output from about 5.7 million barrels a day at present to less than 4 million to support the official price. CAPTION: Picture 1, AHMED ZAKI YAMANI. . . expected to pressure Saudi competitors; Picture 2, KING FAHD. . . committed to $34 price