Washington — Once again the US Congress has followed its tradition of backing the President on foreign policy. Members evoked memories of the quagmire of the Vietnam war, and some critics prophesied certain failure for current United States policies. Nevertheless, the Senate voted 54 to 46 Thursday to go along with the House and authorize President Reagan to keep 1,200 marines in their peacekeeping role in strife-torn Lebanon for up to 18 months.
The bill that now goes to the President's desk offers something for both the Legislature and the White House. For the first time ever it invokes the War Powers Resolution of 1973, which gives Congress authority over sending troops into hostilities. At the same time, the compromise sidesteps a looming constitutional crisis over warmaking powers by voting to allow the troops to stay in Lebanon.
Buoyed by the current cease-fire among feuding factions in Lebanon, supporters won passage of the compromise even as the Washington Post released a poll showing that only 29 percent of Americans approve of keeping the troops in Lebanon for 18 more months.
But despite the success of the compromise, the slim margin in the Senate and the united Democratic opposition foreshadow possible future problems for President Reagan.
Bipartisan foreign policy, which has been the rule on Capitol Hill, has been endangered by disputes over Central America policy.
In the Senate, party cooperation broke down completely over Lebanon. Even the venerable Sen. John C. Stennis (D) of Mississippi, who has long espoused a doctrine of support for the presidency, voted for a Democratic proposal to throw out the 18-month agreement and put much stiffer restraints on the President.
Sen. Sam Nunn (D) of Georgia, one of the top congressional experts on the military, told his colleagues that the compromise, which was worked out mainly by the White House, Senate Republicans, and the House leadership, was ''the worst of all worlds.''
He charged that the Lebanon resolution outlines ''unlimited'' goals and then limits the amount of US forces as well as giving them too little time.
''We'd better have an amendment that's going to go five years or 10 years,'' said Senator Nunn, citing the broad aims of US policy.
Nunn and fellow Democrats object chiefly to the ''findings and purpose'' in the Lebanon resolution, which states that the ''removal of all foreign forces from Lebanon is an essential United States foreign policy objective.'' Moreover, the resolution says that the multinational peacekeeping forces are in Lebanon to ''restore'' control to that country's central government.
''What if Syria decides to say, 'We ain't ever leaving'? Does that mean we ain't ever leaving either?'' said Sen. Dale Bumpers (D) of Arkansas.
''I can't even name all the players in Lebanon,'' Senator Bumpers told his colleagues, charging that bringing order would be impossible with so little US force. ''When you consider all the parties there, I invite you to tell this body the kind of government you envision.''
Comparing Lebanon with Vietnam, he said, ''The parallel is not perfect.'' But the Arkansas Democrat added, ''There are enough lessons to be learned from Vietnam that we ought not to do what we're about to do.''
Over such objections, the Senate went along with the compromise because the Republicans have the majority.
However, credit for passing the Lebanon agreement goes not to the Republicans , but chiefly to the Democrat who has been President Reagan's primary antagonist , House Speaker Thomas P. O'Neill Jr.
The speaker, who is the first to oppose the Reagan administration on domestic issues, went to bat for the Lebanon policy, despite a mutiny among many in his own party. While Democrats in the Senate foresaw disaster, Mr. O'Neill went into the well of the House Wednesday and gave a rousing, optimistic speech.
He supported the Lebanon resolution, he said, ''because I believe, first, that the withdrawal of all foreign troops from Lebanon, and the establishment of a free, sovereign, independent Lebanon, is a very real possibility.
''I believe sincerely'' that negotiations will promote stability and peace in Lebanon, he told the House, and ''I believe in my heart that it is going to mean an early departure of our marines. I truly believe that.''
But the speaker has frequently conceded that sending troops abroad into hostile areas is not popular with the ''man on the street.'' And if his optimistic view is wrong, Congress is certain to have the Lebanon issue before it once more.