Saudi Arabia's King Khalid, ruler of the world's wealthiest and most powerful oil-exporting country, died yesterday in the royal summer capital of Taif following a heart attack. His half-brother, Crown Prince Fahd, was immediately proclaimed as the desert kingdom's new monarch.

Khalid ibn Abdul-Aziz ibn Saud, who was 69, had been in poor health since coming to the throne in March 1975, and the swift succession that occurred yesterday had been carefully planned by the Saud family's council of elders. Fahd, 60, had been the country's acting prime minister under Khalid, a retiring and pious man, and no immediate changes in foreign or petroleum policies are expected for a key American ally in the Middle East.

Fahd was more closely identified than was Khalid with government plans for using Saudi Arabia's staggering oil revenues for modernization. Moreover, he heads a group within the royal family that has in recent years favored closer cooperation with the United States. Secretary of State Alexander M. Haig Jr. yesterday called Fahd "a close friend and collaborator" of the United States.

The official announcement of Khalid's death, read over Riyadh radio and monitored abroad, also said that Prince Abdullah, the commander of the National Guard, had been named crown prince. The action formally places Abdullah in line as heir to the throne and appeared to resolve the most divisive issue of succession facing the royal family.

Khalid, whose interests ran to desert falconry and the simple life of Bedouin tribesmen rather than to governing, had to be persuaded by family elders seven years ago to become king, in part because he could bridge differences between Fahd and the more traditionalist Abdullah, whose National Guard is a largely Bedouin force that is a counterweight to the Saudi Army. Abdullah, 58, is an outspoken supporter of Arab nationalism and the Palestinian movement.

After a lackluster start as the effective day-to-day ruler of the kingdom, Fahd has applied himself seriously to the job in recent years and has forged a working alliance with Abdullah.

Saudi state television announced last night that Abdullah would serve as first deputy prime minister, and the defense minister, Prince Sultan, would become second deputy prime minister. Sultan, who commands the Army and is from the same branch of the royal family as Fahd, thus becomes the third-ranking leader in the Saudi hierarchy. The television broadcast said there would be no other changes in the Cabinet, news agencies reported from Riyadh.

Khalid was buried just before sundown, about seven hours after his death, in the royal cemetery in Riyadh. The simple ceremony was attended by Persian Gulf rulers and tribal notables.

Because of his poor health and almost painful shyness in dealing with foreigners, Khalid was originally seen as a figurehead by many observers. But he proved to be an adept conciliator in Saudi and Arab politics as he carefully balanced the competing demands of a once poor and backward country that is likely to earn more than $80 billion in oil revenue this year.

Khalid's reign was marked by a physical transformation of the country that his father, Abdul Aziz ibn Saud, founded as a modern nation in 1932. A five-year plan that had cost about $150 billion by its end in 1980 bought for Saudi Arabia the world's most modern and expensively constructed hospitals, universities and hotels for a population estimated at 5 million Saudis.

It also brought growing numbers of foreign workers, who caused strains in the country's strict Wahabist Islamic society, and it brought growing corruption that radical Arab opponents of the 2,000-member network of royal princes--who form the country's only political system--have seized upon to demand change.

Politically, Khalid presided over a dramatic if often uneven increase in Saudi Arabia's involvement in Middle East politics, in Saudi efforts to lead Islamic nations as a political bloc and in his country's open reliance on the United States to provide the most sophisticated military equipment available and a discreet military umbrella against outside attack.

In May 1975, two months after he had been brought to power by the assassination of his half-brother, King Faisal, Khalid shifted the kingdom's position on the Middle East conflict by saying in an interview that Saudi Arabia would coexist with an Israel that withdrew from the territories occupied in the 1967 war. His remarks, delivered in a halting murmur and an air of extreme reserve, were the kind of clear expression of goals and limits that Faisal had always avoided.

This sentiment has been voiced in various ways by Saudi officials since, most prominently by Fahd in developing last year an outline of conditions for an Arab-Israeli peace settlement that became known as the eight-point "Fahd plan." The Saudis failed to get an endorsement of the plan from an aborted Arab summit meeting in November, but Fahd as king may now push even more actively for a settlement that the Saudis see as necessary to halt pressures rising from Palestinian radicalism and from Israel's occupation of Arab territories.

Messages of tribute were sent from across the Arab world, including from the Palestine Liberation Organization, which the Saudis have strongly supported.

Egyptian President Hosni Mubarak took a major step toward ending a three-year-old Egyptian-Saudi rift by announcing that he would fly to Saudi Arabia today to extend his condolences to the royal family and by issuing a public statement extolling Khalid as a "symbol of Arab and Islamic solidarity and a man of vision." Saudi Arabia cut off economic aid and diplomatic relations with Egypt in 1979 after Anwar Sadat made peace with Israel.

Mubarak's move reflects his eagerness to improve relations with the kingdom, which was Egypt's chief bankroller and ally in the region until Egypt made a separate peace with Israel three years ago, special correspondent Olfat Tohamy reported from Cairo.

Although an immediate restoration of full relations is not expected, Egytian officials reportedly hope Mubarak's meeting with King Fahd will lead to a softening of the Saudi stand on this issue. The two men had established a personal rapport in the past, when Mubarak, as vice president, was often dispatched to Saudi Arabia.

Washington Post correspondent David B. Ottaway reported from Beirut:

Sobbing during a brief radio broadcast that followed the burial, Fahd told Saudi Arabia, "We will continue his path, seek to realize his hopes and complete his plan. We seek nothing but the glory of Arabs and Moslems."

King Khalid reigned more than he ruled during his seven years as monarch, although it was widely said that his view usually prevailed within the family whenever he did care to assert his authority.

His role at first was highly uncertain, because no sooner had he come to power than he gave a written authorization to Fahd to run the kingdom's day-to-day affairs.

Born in 1912 in Riyadh, Khalid was known as "the man of the desert" because of his delight at visiting with nomads and tribesmen and drinking camel's milk under the tent with them.

The former Saudi ambassador to the United Nations, Jamil Baroody, once described Khalid as a true father figure for Saudi tribesmen "with a natural dignity of the tribal Saudis."

Khalid was one of 45 sons born to King Abdul Aziz ibn Saud, the founder of modern-day Saudi Arabia. He was educated by Islamic tutors in the former traditional fashion and thoroughly drilled in the Koran and Wahabbist teachings, which he closely followed throughout his life.

While he was never one of the ruling Saudi families' most dynamic members, his piety and lack of enemies served him well and were among the reasons he was named crown prince in 1965 and then king a decade later. His older brother Mohammed was actually first in line by age under the Saudi system, in which succession goes down the line of the male heirs born to Abdul Aziz. But senior members of the family either decided he was not the man for the job, or Mohammed himself declined.

Khalid was in and out of Saudi politics in his early years, and little notice was taken of him after he first became crown prince in 1965, reportedly with the backing of Prince Abdullah.

Khalid ruled the kingdom at a time of almost continuous challenges from abroad.

Two years after he was installed, the Saudi kingdom was forced to deal with a major fissure in the Arab world resulting from the late Egyptian president Anwar Sadat's trip to Jerusalem in November 1977 and his subsequent peace treaty with Israel in March 1979.

Since Saudi Arabia regards itself as the protector of Moslem holy places and a leader of the Arab effort to regain control of those in Jerusalem, Sadat's trip and treaty came as a real shock, all the more so because Egypt was then regarded by the kingdom as an ally. Khalid in particular reportedly felt a deep sense of betrayal and bitterness.

Furthermore, the involvement of then-president Carter in promoting the Camp David accords, which led to the Egyptian-Israeli peace treaty, put enormous pressure on the Saudi traditional alliance with Washington.

King Khalid's major role throughout this time of regional turmoil and internal Saudi stress was to act as a keel in maintaining the royal family's stability and legitimacy with the tribesmen of the interior. He loved to go on trips in the desert for hunting with his falcons or to sit under a tent and talk with Bedouins.

After religious extremists laid siege to the Grand Mosque in Mecca in November 1979 and forced the royal family to take it back by force, he toured the kingdom to renew the family's contacts and allegiances with the various key tribes of the kingdom. He even met with the restless Shiite minority in the eastern province, attracted by the religious call of the brethren across the Persian Gulf in Iran.

It was the role he played best and reports at the time said he had been extremely effective in reconsolidating support for the ruling Saudi family.

Khalid divided his life between the ceremonial duties of king, chief mediator of intrafamily disputes and relaxation at his farm in the desert outside Riyadh at Um Hamam.

In 1980, he had a special car designed for his falcon hunting, which was said to have six wheels, an 80-gallon gas tank and a seat operated hydraulically so that he could release his falcons through the drawn-back sunroof.

During the last years of his life, he was constantly followed around when traveling by a mobile hospital, and when he went abroad he took with him a Boeing 747 specially equipped with operating room.

Khalid suffered a first heart attack in 1970 and underwent open heart surgery two years later at the Cleveland Clinic. He had another six-hour operation there for a double coronary bypass in 1978.