A small circle of key White House advisers discussed replacing Secretary of State Alexander M. Haig Jr. with George P. Shultz several days before Haig resigned, administration sources said yesterday.

These sources said that Shultz's name headed a list of five prospective replacements that also contained the names of Haig's chief rival in the administration, Secretary of Defense Caspar W. Weinberger, and White House chief of staff James A. Baker III.

Shultz quickly emerged as the consensus choice because of his experience, his harmonious style and his high standing with America's European allies.

In fact, Shultz was the first choice for State by a number of advisers when President-elect Reagan was assembling his Cabinet after the 1980 election. He impressed Reagan and his top advisers before the president's recent European trip when Shultz briefed them on the results of the preliminary visit to the same European capitals.

While Shultz was always a potential replacement for Haig, the subject became an urgent topic of conversation after Reagan returned from Europe on June 11.

Haig complained increasingly that too many voices, including those of national security adviser William P. Clark and Vice President Bush, were being heard on foreign policy. In the White House view, the clashes of personality and constant friction that one aide referred to as "500,000 little offenses" made it impossible for Reagan to carry out his original goal of deferring any change until after the 1982 elections.

Early last week, according to administration sources, the subject of Haig's replacement was discussed by a tight-knit group that included Baker, Clark and deputy White House chief of staff Michael K. Deaver. Bush was kept informed. The group agreed that the situation between Haig and the White House had deteriorated so badly that Haig would have to go.

There was never any need to discuss "firing" the secretary of state, these sources emphasized. Haig had been threatening to resign perodically, they said, and the White House aides knew he was ready to exercise this option. This was confirmed Wednesday when the secretary of state requested a meeting with the president the following day.

The meeting took place at 9:30 a.m. Thursday in the Oval Office, with only Reagan and Haig present. Afterward, Reagan told some of his White House advisers that Haig had objected to the conflicting voices being raised on foreign policy issues and had also cited policy differences.

"What policy differences?" Reagan said he replied.

Haig then cited differences on U.S-Soviet relations and on China policy, where the secretary of state consistently has opposed sending spare parts and other equipment to Taiwan.

It is not known what the secretary of state said directly to the president, but Haig associates said he referred to a long accumulation of differences, including Reagan's decision to extend sanctions preventing export of material for use on the Soviet gas pipeline to Europe, and, most crucially, the recent differences within the administration on how to respond to the Israeli invasion of Lebanon.

Though Haig has voiced his anger at various White House officials, especially Clark, in the last few weeks, his mood in the meeting with the president was described as "temperate" by a White House official. He said during the meeting that he would submit a written resignation the next day.

Haig had prepared a letter detailing his grievances on many issues and his differences with the White House staff, administration officials said. The letter was rewritten four times after long discussions with Clark and other officials until the final, generally worded version was produced Friday.

The inner circle of White House advisers, all of whom were largely relieved that Haig was resigning, had two worries after the meeting. The first was about Shultz. To accomplish the change with a minimum of public upset, the advisers believed, they needed to have Shultz announced as Haig's replacement at the same time the president publicly disclosed the resignation.

An adviser who said that the inner circle was worried about whether Shultz would accept was asked what the White House would have done if he had refused.

"We'd have been up a creek without a paddle," the official said.

But there was general agreement that it would be difficult for Shultz to turn down the president in a crisis. To make sure, an intermediary, who was not identified, telephoned Shultz just before the president talked to him on Thursday and assured Reagan that Shultz was willing to take the job.

According to White House sources, Haig had agreed to submit his resignation by 2:30 p.m. Friday and the president was due to announce it a half hour later. But the letter, which Haig had written and rewritten, had not arrived when Reagan went before the television cameras shortly after 3 p.m. One aide speculated that this was the reason the president appeared somewhat shaken, because White House officials had by this time begun to wonder what Haig would actually do. The letter finally arrived at 4:20 p.m., shortly before the secretary of state went on national television.

Throughout the week, as the impending resignation was discussed in the tight-knit White House circle, the information was withheld from other key members of the staff.

One official said that even White House counselor Edwin Meese III did not know that a resignation was imminent. On Wednesday, responding to a reporter's question at a Washington Press Club luncheon, Meese minimized the differences between Haig and Clark. Another source, close to Meese, said the counselor was aware of the problems but did not think they were reaching a climax culminating in Haig's resignation.

Other White House officials, including communications director David Gergen and deputy press secretary Larry Speakes, were not informed that anything was afoot until Friday, shortly before Reagan announced the resignation on television.

In reviewing what happened yesterday, White House officials reverted to their basic explanation of the day before, which is that a long series of personality conflicts with the prickly Haig gradually undermined the trust of Reagan and his principal advisers. They acknowledged, however, that there were policy differences as well, particularly on the process by which foreign policy is conducted.

"However, the policy differences could have been reconciled except for the underlying personality conflict," said one administration source.

One of Haig's principal complaints was that the essential agreement under which he took the job -- that he would be the sole spokesman for foreign policy -- had steadily eroded. He told one friend that he had lost authority to Bush, Baker, Clark and Weinberger.

What was not known yesterday was the extent of Reagan's involvement in the process that led to Haig's resignation. But his role, as described by administration officials, appears to have followed the pattern of his sometimes delegated presidency and of his two terms as governor of California. Reagan is usually reluctant to make a major personnel change until all his principal advisers agree.

In this case, said one official, the president had reached a decision before the European trip that some change was necessary, but didn't act because there wasn't a consensus. This official said that Clark, who had been Haig's deputy, was "the last to cross the line" in agreeing to a change, but that the actual decision was made by Haig.

The president's own acceptance of the change, one source said, may have been encouraged by Nancy Reagan, who reportedly concluded about three months ago that Haig was tempermentally incompatible with other high officials in her husband's administration. Though Mrs. Reagan disavows any policy role, her views, particularly when they coincide with those of Deaver, Clark and Baker, are considered consistently influential on major personnel decisions.