The Reagan administration backed away yesterday from its unqualified endorsement of the Israeli raid on the Palestine Liberation Organization headquarters in Tunis and tried to speak with one voice after top policy makers had sharply disagreed about the appropriate U.S. response.

Secretary of State George P. Shultz and Defense Secretary Caspar W. Weinberger were reported to have been upset by the White House handling of the U.S. reaction to the Israeli raid. Tunisian President Habib Bourguiba also expressed "profound regret" and "great astonishment" at the White House justification of Tuesday's attack as a "legitimate response" and "an expression of self-defense."

Shultz, who is in New York for the United Nations session, was described by various administration sources to have been upset by the tone of the initial White House comments suggesting a total U.S. endorsement of the Israeli action. One source said Shultz telephoned his complaints to Washington.

Shultz had been consulted three times on the wording that the State Department would use in describing U.S. reaction to the raid in an attempt to present a noncommittal and balanced position, one source said.

The White House endorsement of the raid upset Shultz's strategy for dealing with the raid, sources said.

This strategy was reflected in a speech Shultz gave last night before a foreign policy group in New York. "Terrorism is terrorism. It deserves no sanctuary and it must be stopped," Shultz said. Then, in an implicit criticism of Israel, he said, "The truth is unavoidable. There will be no solution for the Middle East unless there is the realization there is no military option. The road to peace lies only through a negotiated settlement."

Weinberger also was described by a senior Pentagon official to be unhappy with "the tone" of White House reaction, although the Pentagon officially refused comment.

Saudi Defense Minister Prince Sultan, in a meeting yesterday with Shultz in New York, expressed "shock" at the Israeli raid and said the White House endorsement had left the kingdom feeling "very uncomfortable," according to a senior administration official.

President Reagan, seeking to appease Arab outrage, sent Bourguiba a letter of "sincere condolences" about the loss of Tunisian lives in the raid. Administration officials also said the United States "deeply deplores" the rising pattern of violence in the Middle East, including the Israeli raid.

At the same time, the White House and State Department issued statements saying that in light of repeated acts of terrorism against Israel recently, "the air strike is understandable as an expression of self-defense."

"While the resort to violence is deplorable," said White House spokesman Larry Speakes, "it is useful to recall the antecedents to this attack, which included repeated attempts to infiltrate terrorists into Israel and the outrageous murder of three Israeli civilians in Larnaca."

He was referring to the Sept. 25 murders of three Israelis in the port city of Larnaca, Cyprus, by three Palestinian terrorists.

The administration still refused to take a position on whether Israel had violated U.S. laws by using American-made warplanes in the raid on the PLO site in Tunisia, which is a close U.S. ally whose territorial integrity the United States has pledged to help defend.

Speakes said there had been no decision yet within the administration whether the Israelis had violated the Arms Export Control Act, which states that U.S. weapons sold abroad must be used "solely for internal security" and "for legitimate self-defense."

This question, together with the strong White House endorsement Tuesday of the Israeli raid have caused considerable debate within the administration itself, according to sources close to Shultz and Weinberger. Both the State Department and Pentagon have let it be known they remain less supportive of the Israeli raid.

Several sources said the Pentagon was concerned that Israel might have violated arms export restrictions. At a meeting with Israeli diplomats Tuesday, defense officials asked for a list of U.S. weapons used in the raid and for Israel's justification for using them. The officials were told that F15 fighters were used in what Israel described as a defensive mission, one source said.

"There never was any question that some American equipment was used," the Pentagon official said. "The issue then becomes whether it was for defensive purposes."

White House and State Department officials yesterday tried to strike a balance between their condemnation of escalating violence in the Middle East and their endorsement of the principle of a nation's right to retaliate against terrorist acts.