Prime Minister Abdul Hamid Sharaf of Jordan, scion of a noble Bedouin warrior and an architect of King Hussein's anti-Camp David policies, died early today of a heart attack as he slept in his Amman mansion.

The sudden death of Mr. Sharaf, 41, robs Hussein of his most trusted and influential adviser on foreign affairs. As such, he advocated firm resistance to U.S. attempts to draw the king into the Palestinian autonomy talks set up in the Egyptian-Israeli peace treaty.

It also takes from the king a respected member of the Hashemite nobility (his father fought alongside Lawrence of Arabia with Hussein's great-grandfather a half-century ago) and a smooth statesman equally at home with Western dipolimats or Arab revolutionaries.

Hussein's voice choked as he announced Sharaf's death this morning over Jordanian radio:

"He was a brave warrior who sacrificed himself to Arab causes, particularly the cause of Palestine," the king said. "He is a martyr."

Mr. Sharaf first became known in the United States as Jordanian ambassador to Washington after the 1967 Arab-Israeli war until 1972, when he became Jordan's permanent delegate to the United Nations. While in the United States, he obtained a doctorate in international relations from Georgetown University. Since his departure in 1976 to become Hussein's chief adviser in Amman, Mr. Sharaf had returned more times alone and with the king, most recently two weeks ago during the monarch's visit to Washington.

It was Mr. Sharaf's dual background that made him particularly valuable to Hussein. On one hand, Mr. Sharaf was a "sharif," or nobleman, in the Hashemite hierarchy. His father, the Sharif Sharaf, had fought with Sharif Hussein in the 1916 Arab revolt against the Turks and later served with King Faisal during the Hashemite rule in Baghdad.

When the British expelled Sharif Sharaf from Iraq to Rhodesia in 1941 on charges of cooperating with the Germans, Abdul Hamid Sharaf fled with his mother and a brother to Istanbul. King Abdullah of Jordan, King Hussein's grandfather, recalled the family to Amman in 1945 and the young Sharaf spent most of his boyhood there as part of the ruling class.

On the other hand, the young Sharaf had joined the fledgling Arab Nationalist Movement during the later student days at the American University of Beirut. The movement, founded in 1952 by Dr. George Habash, now head of the Popular Front for the Liberation of Palestine, is considered the seedbed for much of today's radical Arab nationalism.

As a result, Mr. Sharaf was considered especially qualified as a negotiator in the increasing dialogue between Hussein's government and the Palestine Liberation Organization of Yasser Arafat. Simultaneously, his western education and polished manners made him Hussein's irequent choice for delecate missions to Europe and the United States.

Mr. Sharaf also was considered a major force behind Hussein's steadily improving relations with Baghdad where Mr. Sharaf was born in 1939. He had urged alignment with Syria for a firm stand against the peace agreement between Egypt and Israel and the autonomous rule planned for the West Bank as part of the deal worked out by the United States.

He served Hussein as chief of the royal cabinet from his return to Jordan in 1976 until last Dec. 19, when the king named him prime minister, foreign minister and defense minister.

That appointment was interpreted as a demonstration of Hussein's good faith in his reapprochement with Arafat's guerrillas and his commitment to the Baghdad group of Arab nations opposed to the Camp David peace process. Hussein is known to believe strongly in the same policies, and observers did not expect Mr. Sharaf's death to have any swift effect on Jordan's attitude toward the Camp David talks.

Hussein immediately named agriculture minister Qassim Reimawi to replace Mr. Sharaf as prime minister and defendse minister. Reimawi, 60, is a Palestinian from Ramallah on the Israeli-occupied West Bank just north of Jerusalem. His appointemnt was interpreted as a sign of Hussein's continuing concern for the West Bank, which Jordan ruled from 1948 until it was conquered by Israel in the 1967 war.

Reimawi named Marwan Qassim, former minister of state for foreign affairs, as foreign minister and he called on Suleiman Arrar to take over the agriculature portfolio.

Mr. Sharaf is survived by his Lebanese wife, Leila Najjar, and two sons.

His funeral, which under normal Moslem custom would have taken place the day of death, was postponed until Friday to allow time for his brother, Fawaz, to return from Washington, where Mr. Sharaf recently had dispatched him to follow in his footsteps as Jordanian ambassador.