While President Reagan slept, the U.S. government switched positions on a controversial United Nations resolution without telling him, Secretary of State Alexander M. Haig Jr. said today.

Haig acknowledged that he decided to have Jeane J. Kirkpatrick, the U.S. ambassador to the United Nations, abstain on a Panamanian-Spanish resolution, opposed by Britain, that aimed at producing a diplomatic solution to the Falklands conflict. Kirkpatrick, however, voted with Britain against the resolution because the instructions telling her to abstain did not arrive in New York in time for the roll call yesterday.

Asked why he hadn't called Kirkpatrick directly, Haig said of the U.N. ambassador, who has Cabinet rank but is held in low regard by Haig: "You don't talk to a company commander when you have a corps in between."

The remark revealed an open secret of the Reagan administration, which is that Haig and Kirkpatrick are barely on speaking terms. Some officials here were critical both of the secretary of state and of the U.N. ambassador--of Haig for not calling the instructions directly to New York and of Kirkpatrick for drawing attention to the change in instructions after she had cast her vote.

The incident proved an embarrassment to Reagan, who had hoped to demonstrate qualities of competence and leadership during this weekend's economic summit meeting and the remainder of his 10-day European trip.

"President Reagan came to Europe to try to prove that he could ride, and he instead fell off his horse at the first fence," said a British television commentator, reflecting the mystification of his country's delegation at the U.S. action. British sources said that Foreign Secretary Francis Pym "expressed dismay" when Haig informed him of the U.S. intention to abstain minutes before the vote was taken.

The incident recalled an occasion in 1980 when a U.S. representative in the United Nations voted for an anti-Israeli resolution and subsequently changed positions after a wave of public criticism. One of the most vocal critics was then-candidate Reagan, who refused to accept president Carter's explanation of a breakdown in communications and instead interpreted the incident as demonstrating a failure of the Carter leadership.

Haig, taking full responsibility for the decision on the U.N. resolution, made light of suggestions that he should have awakened Reagan.

"It was just a nuance vote," he said, adding that if he awoke Reagan for matters like this, "My God, the president would be up 24 hours a day, and I'd be up, too."

Reagan did not learn of the incident until his morning staff meeting and still did not seem very conversant with what had happened when a television reporter caught up with him at lunchtime.

The president, seated between British Prime Minister Margaret Thatcher and Japanese Prime Minister Zenko Suzuki, was asked at the lunch whether the United States had meant to oppose or abstain on the resolution at the United Nations.

"Uh, you've caught me a long ways from there," he replied. "Let me catch up with things of that kind."

When the reporters said that British sources were "furious" about what had happened, Reagan said: "I have no information with which to answer." Thatcher would not comment, beyond saying she did not give interviews at lunchtime.

United Press International said a senior British official who asked not to be identified described the U.S. mixup as "duplicitous." His choice of the word was an apparent tit-for-tat reference to Haig's characterization of former British foreign minister Lord Carrington, whom Haig once called "a duplicitous bastard."

The day before, during a 1 1/2-hour private meeting with Thatcher, Reagan had expressed full support for British efforts to regain control of the disputed Falklands territory by military force.

This in itself was a different view than administration officials, both inside and outside the White House, had conveyed during the week leading up to the meeting. The message that the administration had sent in advance of the Reagan-Thatcher talks was that the president intended to persuade the prime minister to be magnanimous and try to avoid a bloody battle for the Falklands capital of Stanley.

When this view changed to one of all-out backing for the British, it apparently failed to carry along Kirkpatrick. She remained concerned that too close an identification of U.S. and British interests would damage U.S. standing among Third World countries, particularly in Latin America. Because of these views, White House officials said that Kirkpatrick consistently favored abstention rather than opposition to the Panamanian-Spanish resolution.

This view ultimately proved indirectly persuasive with a secretary of state and an administration that give a relatively low priority to the United Nations and were preoccupied this week with the many thorny issues of the summit.

Haig had discussed the resolution with Pym earlier in the day without focusing on details. The British believed from what Haig said that the United States intended to join them in opposition to the resolution as a sign of Anglo-American solidarity on the Falklands issue.

Shortly after 11 p.m. 5 p.m. EDT yesterday, Haig discussed the resolution by telephone with Deputy Secretary of State Walter Stoessel and Assistant Secretary of State Thomas O. Enders in Washington. Both of them supported Kirkpatrick's view and recommended an abstention rather than a veto, officials here said today.

Haig then called Pym, who was out. He also called National Security Adviser William P. Clark, who also was away. Then he called back the State Department in Washington and gave the instructions that Kirkpatrick should abstain.

By the time Haig reached Pym and Clark in subsequent phone calls, he believed that the instructions had been carried out. He learned a few moments later, however, that the message had failed to reach Kirkpatrick in time.

A minor mystery remained over whether Kirkpatrick had been instructed to announce the intended abstention--as she said yesterday--or decided, as Haig today suggested, to do this on her own. White House officials said they didn't know which version was accurate.

The incident revived some of the long-festering animosities between the White House staff and Haig, which had notably diminished during the past five months after Clark became national security adviser. The inclination in the White House, at least today, was to dismiss the most recent incident as an aberration rather than an episode that presaged a new period of conflict between the White House and Haig.

"It's unfortunate as hell," said one high-placed White House aide, "but I do think Al had the authority to make the decision."

Another high-ranking official, while saying that he wished Haig had mentioned to the president what he was going to do, excused the secretary on the grounds that he was preoccupied with many other issues.

"There was so much going on here that the resolution really wasn't given that much significance, though perhaps it should have been," this official said. "Al didn't focus on it."

Haig, asked whether the administration was trying to have it both ways, had the last word. "If we are," he replied with a smile, "it's proved that's not the way to do it, not at all."