King Khalid Ibn Abdul Aziz, the sovereign monarch of Saudi Arabia and a man whose decisions on oil can determine the industrialized West's fate, ordered his subjects to pray for rain late last month.

It was a pious, simple act, much in keeping with the traditional cares and hopes of the Saudi monarchy: the kingdom needed rain, so the monarch bade his subjects to turn to Allah for relief.

Not all the king's decisions are so simple, however, for the problems besetting the Saudi royal family have become much more complex, much less given to solution by an act of prayer. The timing of the king's fiat was a dramatic reminder of the multiple pressures on the Saudi royal house.

As King Khalid spoke, Islamic extremists already were filtering into Mecca with arms and ammunition for the spectacular takeover of the Great Mosque that would begin at dawn the next day and send the royal family into its most dramatic crisis since the assassination of King Faisal in 1975.

If this assault on the monarchy's religious underpinning was not enough to worry about, U.S. Treasury Secretary G. William Miller was on his way here to plead once again for the royal family's understanding and cooperation in its use of its vast wealth and petroleum resources.

Like it or not -- and there are signs that many Saudis do not -- Saudi Arabia's recently acquired status as a world economic power has pushed it into a complicated web of strategic relations with other Arab nations, Europe and the United States. As a result, important decisions taken in Riyadh or Jeddah send ripples through the divided Middle East, the oil-hungry West and beyond.

In addition, the Iranian revolution just across the Perisan Gulf and the current of Islamic fundamentalism flowing from it have mixed a volatile new ingredient into Saudi Arabia's relations with the rest of the Moslem world -- and perhaps even with some of its own people.

There was little affection here for the shah of Iran. But his departure and the emergence of Ayatollah Ruhollah Khomeini's Islamic republic have created dangerous uncertainties for security in the Gulf, through which pass about two-thirds of the West's oil imports and most of Saudi Arabia's exports. Now the takeover of the Great Mosque of Mecca by Moslem commandos has underscored for the Saudi royal family the extent to which Islamic reaction can become a contagious disease -- even here.

The Saudi leadership is wrestling with these problems as it also approaches a series of key decision on how much oil to produce, how much to charge for it and how best to use the wealth is produces for the kingdom.

"This wealth that has been bequeathed on Saudi Arabia, it's not really a pleasure, it's an awesome responsibility," said Fouad Farsy, the U.S. educated deputy industry minister and an authority on the kingdom's development problems.

The complications were starkly apparent over the last week and a half as Miller came calling with oil on his mind even as Saudi National Guardsmen fought to dislodge the Moslem fanatics at Mecca.

Miller's three-day stay here was referred to by a cynical American diplomat as "petroleum pilgrimage." The meaning was obvious: just as the Moslem faithful stream to Mecca to pray for salvation each year, U.S. treasury secretaries fly into Saudi Arabia to plead for Saudi help in keeping oil prices down and pumping levels up.

Miller apparently came away with no new assurances of Saudi help in meeting Washinton's oil needs. In fact, sources with access to the highest level Saudi thinking say the top advocates of less flexibility toward American requirements and more attention to strictly Saudi needs are gaining influence. Ironically, they are mostly Western-educated and young and reportedly include:

Prince Saud Faisal, the Princeton-educated foreign minister; Hisham Nazer, the planning minister who graduated from UCLA; Mohammed Aba Khail, the finance and national economy minister, a University of Cairo graduate; Ghazi Qusaybi, industry and edlectricity minister with a master's degree from the University of Southern California and a Ph. D. in international relations from the University of London; and Abdul Aziz Qoreiche the U.S.-educated head of the Saudi Arabian Monetary Authority, or central bank.

These five and some of their aides are reported to have argued against the Saudi decision to heed President Carter's plea last summer to increase daily oil production by a million barrels, to about 9.5 million through the end of the year. Similarly, the informants say, they are opposing any decision to extend the high pumping level into 1980. The decision is due in January.

Some Saudis are proposing a drop even below 8.5 million barrels a day. In its most extreme formulation, their position resembles that of the young Saudi economic official who said: "It is our sovereign right to produce as much as we want and to sell it at the price we want. If people think it's too high, they don't have to buy it."

"We could go one, two, three years sacrificing for the free world," said another young Turk, deputy commerce minister Youssef Hamdan. "But this cannot go on for ever. The rest of the free world should understand this and it should take measures to reduce consumption."

The chief argument of Hamdan and those who think like him in the government is that Saudi Arabia, to accommodate the United States and Europe, is pumping away the resources of future Saudi generation and getting in return only dollars that buy less and less every year.

"I don't like to accomodate too much," said the University of Texas educated technocrat. "The future generations will receive less than they should in real terms."

Although Saudi Arabia spent everything it earned and twice dipped into its reserves for about $4 billion in late 1978 and early 1979, the last price increase by the Organization of Petroleum Exporting Countries (OPEC) and last summer's production increase have again generated a surplus, forecast at more than $3 billion this year. Rather than piling up this surplus, the argument goes, Saudi Arabia should leave the oil in the ground, where it can become more valuable.

Prince Fahd Ibn Abdul Aziz, the crown prince and chief Saudi decision-maker, is aid to feel a strong sense of repsonsiblity toward the rest of the world, however. The decision to increase production last summer was mainly his. Saudi and foreign observers say he also will be the one to make the decisoin on extending the high production level for next year.

Fahd also is the key to Saudi policies on oil prices for the OPEC meeting scheduled this month in Caracas. Some Saudi sources have suggested he will insist on a tough Saudi stand to keep on OPEC increase down to about 20 percent above the current $23 ceiling, even at the cost of exploding the world cartel.

But Miller was told clearly during his visit here that Fahd has not made up his mind on either production levels or prices and that he is unlikely to do until the last minute because of volatile markey conditions. Much oil is being sold at prices far above official OPEC standards.

According to sources with nearly a decade of close dealings with the royal family, Fahd is likely in the next few weeks to consult chiefly with his two most powerful brothers after the king. These are Prince Sultan Ibn Abdul Aziz, the defense minister, and Prince Abdullah Ibn Abdul Aziz, commander of the National Guard.

Into their deliberations go the technical arguments of Oil Minister Ahmed Zaki Yamani and, the sources said, the diplomatic arguments of their nephew Prince Saud. But finally, they said, the decision grows from instinctive family conclusions about what should be done, and in the tradition of bedouin councils the outcome is taken to Khalid for ultimate approval.

No bedouin council, however, had to deal with the conflicting pressure of Fahd and his royal brothers. Their decision can create lines in front of gas stations in the United States or it can make it hard to heat West German homes. It can lead to a drop in the dollar's value or a rise in the yen.

The Saudi family also feels a traditional obligation to support the Arab cause against Israel. The importance of Saudi oil makes it a powerful potential weapon against Israel's supporters, particularly the United States. The Palestine Liberation Organization repeatedly has called for renewed use of the oil weapon and PLO chief Yasser Arafat has visited Riyadh twice in recent weeks.

At the same time, Saudi officials report growing concern inside the kingdom over the pace of oil-fueled economic development and its effect on traditional Saudi and Islamic values. Fahd has personally pushed hard for high spending and swift modernization. His government has projected expenditures of $142 billion in its five-year development plan ending next year. Riyadh has few streets without construction sites and giant industrial cities are rising at Jubeil on the Persian Gulf and Yanbo on the Red Sea.

The government has been careful to retain conservative Moslem strictures despite the growth. Alcohol is strictly barred. The manager of a Riyadh hotel was jailed last month because the hotel's Thanksgiving dinner menu for foreigners include "champagne." Hotel employes explained too late that the menu really was meant to say "Saudi champagne," a mixture of sparkling water and apple juice that looks like champagne but tastes like what it is.

The influx of foreign workers -- about a third of the nation's 7 million inhabitants are foreign and they make up 70 percent of the work force -- nevertheless has had an inevitable effect. Saudi women still are rarely seen on the street and their faces are almost always covered when they go out. But foreign women with bare faces and arms can easily be seen in the major cities and the Saudi state television often shows women in western dress.

Within a two-minute drive of the sparkling new King Faisal hospital in Riyadh is an auto junkyard, piles of stell carcasses standing helter-skelter across the street from a pre-fab school.

Even as Saudis grow used to such sights, the argument of those who urge more care if likely to be strengthened by the takeover of the Mecca mosque.

The Saudi royal government went out of its way to portray the attackers as deviationists "outside the Islamic religion." Few observers openly doubt the government contention that the violence reflected only a minuscule minority among the Saudi population.

At the same time, however, diplomatic noted that the reformist Moslem themes the gunmen cited have been the object of earlier demonstrations probably echo the feeling of many conservative Saudis upset at the speed of modernization.

While contending with these pressures Fahd also has to keep his eye on the special relationship with the United States that has become the main pillar of Saudi security policy.

In the assessment of knowledgeable observers here, this is the overridding principle on which Fahd makes his decisions. In his view, they say, Saudi Arabia depends on the United States for security from possible external threats and, ultimately, from internal threats to the royal family.