Secretary of State George P. Shultz said yesterday that the American public must give its approval "before the fact" to U.S. military action against terrorism, even if innocent lives may be lost, so that the United States will not become "the Hamlet of nations, worrying endlessly over whether and how to respond."

In calling for public support of a military approach to combating terrorism, Shultz warned that the U.S. response could require not only "swift and sure retaliation" but military strikes against presumed terrorists who have not yet done anything.

The action also might be taken "before each and every fact is known," or on evidence that could not stand up in court, Shultz said. "Fighting terrorism will not be a clean or pleasant contest, but we have no choice but to play it," he said.

Acknowledging that the approach faces "obstacles . . . precisely because we are democracies," Shultz assailed "moral confusion" on the issue and called for a national consensus.

The harshly worded speech, delivered at the Park Avenue Synagogue in New York last night, was the closest thing to a warning of impending military action that an administration figure has given since President Reagan signed a secret presidential directive last April authorizing an undefined "offensive" against terrorism.

It also appeared to be a response to criticism that the administration's proposed legislation to bar aid to terrorists would violate the Constitution because of problems in listing and defining both aid and terrorism. Congress approved only measures to strengthen existing compacts on airline hijacking and to reward informers on terrorists.

"We will certainly not alter the democratic values we so cherish in order to fight terrorism," Shultz promised. "We will have to find ways to fight back without undermining everything we stand for."

He said Americans are suffering "moral confusion" in equating terrorist acts with terrorists' goals, sometimes "wallowing in self-flagellation or self-doubt" or thinking that attacks are "in some measure our own fault, that we deserved to be bombed" because of faulty U.S. policies.

"Legitimate causes can never justify or excuse terrorism," he said.

Shultz said an effective response posed "hard questions" involving intelligence methods, guidelines for use of force and, "most important of all, our public's attitude" toward the policy.

"We must reach a consensus in this country that our response should go beyond passive defense to consider means of active prevention, preemption and retaliation," Shultz said.

Intelligence services "must be given the mandate and the flexibility to develop techniques of detection and contribute to deterrence and response," he said.

The public must understand "before the fact the risks involved in combating terrorism with overt power," Shultz said. Calling terrorists "depraved opponents of civilization itself," he said the risks of fighting them include "loss of life of some of our fighting men and the loss of life of some innocent people."

"The public must understand before the fact that occasions will come when their government must act before each and every fact is known. . . . Support for U.S. military actions to stop terrorists before they commit some hideous act or in retaliation for an attack on our people is crucial if we are to deal with this challenge."

Although Shultz has spoken previously of the need for U.S. action against terrorism, charging the Soviet Union with supporting it worldwide, he had not before outlined the legal needs and the possible consequences.

"There will not be time for a renewed national debate after every terrorist attack. We may never have the kind of evidence that can stand up in an American court of law," he said.

"But we cannot allow ourselves to become the Hamlet of nations, worrying endlessly over whether and how to respond. A great nation cannot afford to be hamstrung by confusion and indecisiveness," Shultz said.

He repeated a contention he made in July that he has "no trouble" making the distinction between terrorists and "freedom fighters," and added that "we have checked communist aggression and subversion in Central America." But he did not repeat his earlier assertion that the U.S.-backed "contra" rebels in Nicaragua do not employ terrorist tactics.

Contra officials said last week they have assassinated Nicaraguan officials, and the administration has admitted that the CIA mined Nicaraguan harbors and wrote a manual advocating the "selective use of violence" to "neutralize" local leaders in Nicaragua.