President Reagan ordered military operations against Libya after being told of "irrefutable" evidence that Libyan leader Muammar Qaddafi was responsible for the bombing of a West Berlin discotheque and after being warned that the administration's credibility would suffer if he failed to act, officials said yesterday.

The officials said Reagan also was told that Libyan terrorists were planning multiple attacks at American targets on three continents and could be deterred only by direct action. In announcing what he called a "preemptive action" against terrorist operations in Libya, the president said in a nationally televised speech, "We have solid evidence about other attacks Qaddafi has planned against U.S. installations and diplomats, and even American tourists."

Secretary of State George P. Shultz, long the driving force within the administration in behalf of a military response to terrorism, said last night that the administration had information about 30 planned attacks against U.S. installations. Officials say he argued strongly in meetings leading up to Reagan's decision that these attacks could be deterred only if the United States showed it was prepared to retaliate militarily whenever necessary.

Echoing this contention, Reagan and White House spokesman Larry Speakes repeatedly cited "self-defense" last night as the reason for the military strike against Libya. "It is our hope this action will preempt and discourage Libyan attacks against innocent civilians in the future," Speakes said.

Speakes declined to provide details of the decision-making process, but sources said that a formal national security decision directive was signed last Wednesday in which Reagan approved an attack on Libya "in principle." These sources said that the president approved the specifics of the operation yesterday upon Shultz's recommendation.

The secretary of state was backed by national security affairs adviser John M. Poindexter and Vice President Bush, sources said. One senior administration official said the three were "determined" to secure a military response.

These sources said Defense Secretary Caspar W. Weinberger expressed reservations about "some aspects of the military operation" but did not -- as he has in the past -- oppose any sort of military retaliation.

A source familiar with the deliberations that led to the decision said Weinberger had expressed concern about the risk to U.S. servicemen under some of the options considered. Speakes said that every effort was made to limit casualties among U.S. servicemen as well as civilians on the ground in Libya.

The United States had been anticipating a Libyan terrorist response to the U.S. naval exercise in the Gulf of Sidra last month, which prompted a missile attack from Qaddafi and a U.S. response that destroyed two Libyan patrol boats and part of the missile site.

In his report to the American people last night, Reagan confirmed that the United States had advance messages that a site in West Berlin would be attacked on April 5. U.S. officials later intercepted a celebratory message from the Libyan People's Bureau in East Germany to Tripoli, setting in motion the chain of events that led to yesterday's military operation.

In the past, administration officials who favored a military response have found it difficult to achieve a consensus recommendation that could be presented to the president in behalf of a military response. Sources said they worked carefully to build a case this time, and that White House officials were unhappy with U.S. Ambassador to Germany Richard R. Burt when he said -- "prematurely," according to one source -- last Monday that the United States had "clear indications" of Libyan responsibility.

But by Wednesday, when Weinberger was traveling in the Far East and Bush was on a Middle East trip, Shultz and Poindexter were ready with their recommendation for a military strike. Reagan approved the decision in principle at a National Security Council meeting in the Oval Office after hearing a recommendation from Adm. William J. Crowe Jr., chairman of the Joint Chiefs of Staff, who called for adding firepower to U.S. forces before any strike was made. This may have resulted in holding the aircraft carrier USS Coral Sea, which was due to return to Norfolk, in the Mediterranean and adding F111 bombers based in Britain to the strike force.

A source said that it was decided at this meeting to make an attempt to obtain permission from British Prime Minister Margaret Thatcher to use the bombers. The British acceded to the U.S. request after expressing initial reservations, officials said.

Hours after he signed the decision document approving the attack in principle last Wednesday, the president held a nationally televised news conference in which he declined to answer a question about whether he had ordered retaliation, saying this "is like talking about battle plans or something."

Reagan said then that U.S. authorities were still gathering evidence about the West Berlin bombing, in which a U.S. Army sergeant and a Turkish woman were killed and more than 200 persons injured.

"And any action we might take would be dependent on what we learn," the president added. Later in the news conference he said, "And if there's evidence enough to respond, then I think we respond."

In addition to the issue of evidence, officials said, there was also the question of obtaining support from reluctant allies and -- as days passed in what seemed like a war of nerves with Qaddafi -- the backing of congressional leaders, who became increasingly restive about lack of consultation with them.

Many of the congressional anxieties were expressed to Senate Foreign Relations Committee Chairman Richard G. Lugar (R-Ind.), a supporter of retaliation, who last Friday sent a carefully worded message to Shultz asking for formal consultation. Shultz called Lugar on Saturday and invited him to a meeting Monday afternoon at the White House, while U.N. Ambassador Vernon Walters was en route to Europe to consult with allies there.

Walters was successful in Britain, where he received backing for the operation from the government and approval for use of the bombers, but he failed to gain French approval for overflight during the attack.

An operations planning group met Saturday and Sunday in the White House situation room, with Poindexter briefing Reagan at intervals. The president, who spent the weekend at Camp David, returned to the White House on Sunday afternoon and remained in the residence.

Shortly after 4 p.m. yesterday, Reagan and Poindexter went to the Executive Office Building to brief a group of top Democratic and Republican congressional leaders. Senate Majority Leader Robert J. Dole (R-Kan.) said afterward that the briefing was held well before the 7 p.m. attack so the military action could be called off if there was a "strong, strong feeling" by the leaders that it should not go on.

Yesterday's operation was the culmination of an eight-month effort to devise a plan to curb Qaddafi's terrorism or overthrow him. It began after the return of the hostages from the Beirut hijacking of TWA Flight 847, in an options study ordered by then-national security affairs adviser Robert C. McFarlane.

Several options were explored, including a secret U.S. mission to win Egyptian acceptance of a joint U.S.-Egyptian effort to overthrow Qaddafi. That plan was abandoned when it was disclosed publicly and rejected by Cairo.

The collapse of this effort frustrated Shultz and National Security Council officials, who have been trying throughout much of the Reagan presidency to discourage and thwart what they consider to be Qaddafi's adventurism. Reagan promised "swift and effective" retribution to acts of terrorism soon after he became president, but found it difficult to carry out this pledge.

The administration tried economic sanctions against Libya in 1981 with limited success. After terrorist attacks at the Rome and Vienna airports on Dec. 27, 1985, Reagan angrily denounced Qaddafi as a "barbarian" but was dissuaded by Pentagon skepticism from a military response.

"We tried quiet diplomacy, public condemnation, economic sanctions and demonstrations of military force," the president said in his television speech. "None succeeded. Despite our repeated warnings, Qaddafi continued his reckless policy of intimidation, his relentless pursuit of terror. He counted on America to be passive. He counted wrong."

The course the president pursued yesterday demonstrated the ascendancy within the administration of Shultz, who has repeatedly urged a strong response only to find his recommendations trimmed or limited by the reservations of Weinberger and the joint chiefs. Reagan appeared to embrace the Shultz advocacy, not only for this operation but for the future, when he warned that the United States would "do it again" if necessary to deter terrorism or respond to it.

Shultz, briefing reporters on the operation last night, was asked if this operation "settles the score with Libya." In response, he reiterated his view that military operations are preemptive rather than retaliatory.

"It's not a question of settling scores," he said. "It's a question of acting against terrorism, of saying to terrorists that the acts they perpetrate will cost them."