Until about a month ago, the idea of economic warfare against Nicaragua struck most American foreign-policy makers as more headache than gain, an option hardly worth picking up.

A trade embargo involved small change. It would annoy Europe and the rest of Latin America. It would hurt the Nicaraguan middle class. And it would give the leftist Sandinista government of Nicaragua the chance to blame its hungry children on Washington. It was even opposed by the rebels President Reagan is supporting against the Sandinistas; they said their families would suffer more than the government.

One of the strongest opponents of sanctions was Secretary of State George P. Shultz, who has long considered them an ineffective tool of diplomacy.

But when the main thrust of Reagan's approach to Nicaragua was blocked by Congress, all sides suddenly noticed that there was no other policy -- no evidence of tangible American resolve to influence events in Nicaragua. The lawmakers and the administration -- their image as aggressive, decisive decision makers at stake -- joined in grabbing the nearest available option: an economic embargo.

"We didn't even look twice at it" before the debate heated up in Congress, said a middle-level policy planner in the State Department, "and then all of a sudden we were crashing to draw up the program, practically overnight." The embargo went into effect yesterday.

The sudden conversion of lawmakers, the State Department and the White House to the virtues of a U.S. trade embargo against Nicaragua illustrates the way that the government, like a stream, can shoot off in unexpected directions if its forward momentum is suddenly halted.

Administration officials acknowledge that the trade embargo is essentially symbolic -- designed to give the appearance of doing something while they regroup from last month's unexpected rout in Congress. "It's a holding action" until Reagan returns from Europe to approve a renewed attempt to win aid to the "contra" rebels, one said.

Pressuring Nicaragua through the U.S.-backed rebels remains the cornerstone of Reagan's policy toward the Sandinistas. The White House had considered economic sanctions as a possible alternative many times and even did a study of them several months ago that found an embargo not worth the trouble.

Some administration officials continued to advocate sanctions as a complement to rebel aid, arguing -- as the administration has in recent days -- that U.S.-Nicaragua trade of $168 million last year might look small but was important to Nicaragua. It represents 7.3 percent of Nicaragua's gross domestic product; a comparable sum for the U.S. conomy would be $275 billion.

Still, the Commerce Department didn't want to upset U.S. business abroad. Treasury was concerned that an embargo would sandbag tariff reduction talks at the economic summit in Europe. The State Department was "the least enthusiastic" of any agency about the idea, one administration official said.

Foggy Bottom experts pointed out that sanctions had not been much use against Cuba and had been counterproductive when applied against Poland and the Soviet Union. They winced at the prospect of starving Nicaraguans replacing starving Ethiopians on U.S. television screens, with Washington getting the blame.

Some administration officials thought a consensus was forming for sanctions, but nothing had been agreed when Reagan renewed his request for $14 million in military aid to the rebels April 4. A further discussion on sanctions was set for after the vote the week of April 22.

The debate revealed that military aid would not pass. Asking what would, administration lobbyists heard repeated complaints from members of Congress that economic sanctions had not been tried.

Conservative Democrats opposed to military aid but hostile to Nicaragua first broached the idea of sanctions last October. "I'd always opposed sanctions before," said Sen. Lloyd Bentsen (D-Tex.), "but this time I thought at least sanctions would be an overt action we could take." The administration "certainly did resist," he said, but he introduced a resolution calling for a trade embargo on April 22, with moderates Nancy Landon Kassebaum (R-Kan.) and William S. Cohen (R-Maine) as cosponsors.

"I never believed sanctions will make a lot of difference," Kassebaum said. "I just felt it was important to take an action that could be legally done and would show we're not going to carry on business as usual with the Sandinistas."

Sen. David F. Durenberger (R-Minn.), chairman of the Senate intelligence committee, said many senators at a hearing on the administration proposal shortly before the April 23 vote expressed amazement that sanctions were not in effect.

When Shultz met with the Senate Republican caucus that day, he said "the only issue was whether we could tolerate a Soviet country in our hemisphere," according to Durenberger. "I got up and said that was oversimplifying . . . can we tolerate buying bananas from a Soviet communist country and why haven't we done these other things first?"

In a letter hastily written to win over wavering senators, the administration promised Congress to use the aid for nonlethal purposes and to consider economic sanctions, among other things. "Sanctions were added at the absolute insistence of the Democrats," said a State Department official. The measure passed the Senate.

The administration expected the House to chew the plan up but approve something that could go to a House-Senate conference committee. Reagan would have had strong influence there to shape the measure into a form he could label victory.

But House Democrats stunned everybody by moving to avoid just such a conference committee. They refused to pass anything, and the Senate-passed measure became, in the words of a top administration lobbyist, "a beached whale."

Reagan, about to engage Congress on the budget and embroiled in the controversy over his visit to the German cemetery at Bitburg, wanted to be seen as holding the initiative on Nicaragua. Economic sanctions were there to be grabbed.

"I suspect they went away saying, 'if Congress wants economic sanctions, let's give 'em economic sanctions,' " Durenberger said. Administration officials generally confirm that conclusion.

"Let's not blame Reagan for this one, except for getting on the bandwagon," said a State Department official highly critical of the move. "The sanctions came out of Congress' desire to feel better after doing nothing on Nicaragua."

There remained the problem of how legally to justify sanctions. Administration lawyers picked the International Economic Emergency Powers Act of 1977 "because it has very broad powers, it's very flexible and it's more applicable to the situation," a White House official said. The law required a declaration of national emergency, but it allowed almost anything thereafter.

Asked for an opinion on the legality of an embargo under U.S. international treaties and international law, Ralph Tarr, acting head of the Justice Department's Office of Legal Counsel, wrote Reagan that his office could not come to any conclusion, according to informed sources.

A lawyer who recently left the counsel's office said that when the office refuses to give advice it generally means that the office has a "serious problem" with the case. "It's code, and everyone knows it," said the source.

But Tarr said through a spokesman that he "was not aware of any difference of opinion" between the Justice Department and State Department, which told Reagan that sanctions would be legal.

Current and former lawyers at Justice have said they believe that there is a "high probability" that the sanctions violate the Treaty of Friendship, Commerce and Navigation with Nicaragua and possibly the Organization of American States charter, the General Agreement on Tariffs and Trade and the United Nations charter.

Although the friendship treaty is being abrogated as part of the sanctions package, the cancellation will not take effect for a year. Meanwhile the sanctions violate the treaty, these lawyers asserted. Nicaragua's attorney in Washington, Paul Reichler, said he would ask the World Court to rule on the treaty question.

But State Department attorney Michael Kozak said the treaty gives the president authority to terminate the agreement to maintain national security interests and that under that clause the president can suspend trade with Nicaragua immediately. The GATT agreements have a similar clause, he said.

Some senators who advocated sanctions are not happy with this version.

"This is not what I envisioned," said Sen. Sam Nunn (D-Ga.). "I was hoping we'd at least explain it to our allies first and then use the threat of sanctions to get the Sandinistas to talk to their neighbors."

Durenberger agreed. "I kept saying we needed to go through the OAS, to get a regional commitment . . . . What we've got now is gringo sanctions, and our friends who wanted us to send military aid are not joining us."

House Speaker Thomas P. (Tip) O'Neill Jr. (D-Mass.) spoke for many House Democrats who had backed the initial idea. Sanctions "were a terrific bargaining chip," he said. "They should have followed the failure of diplomacy rather than following the failure of the Reagan administration to get its way in Congress."