The Senate gave President Carter a major victory yesterday by voting, 57 to 42, to lift the 3 1/2-year-old embargo on U.S. arms sales to Turkey - a matter the president had called "the most important foreign policy issue facing Congress."

The unexpectedly lopsided vote represented a handsome payoff for Carter's gamble in staking his prestige on the drive to win repeal.

His administration argued that the embargo, imposed by Congress after Turkey's 1974 invasion of Cyprus, has failed to spur the withdrawal of Turkish forces from that island republic and threatens instead to disrupt NATO defenses in the Mediterranean.

However, the administration's fight to turn aside fierce resistance from the Greek-American community and its supporters in Congress is not over.

The House also must approve lifting the embargo. Congressional sources said last night that, despite the outcome in the Senate, the impending House vote - tentatively expected next week - appears too close to call.

With an eye toward that battle, the State Department rushed out a statement last night commending the Senate for its "statesmanlike action," adding: "We are hopeful that the House will act in a similar fashion when it considers this issue."

In winning yesterday's vote, the administration got a big assist from Majority Leader Robert C. Byrd (D-W-Va.) and several other senators, including George McGovern (D-S.D.).

Byrd and McGovern, together with Sens. Lloyd M. Bentsen (D-Tex.) and John H. Chafee (R-R.I.), worked out a compromise that was agreed to by the White House after it became clear that language repealing the embargo without qualification would not pass.

The compromise in the form of an amendment to the fiscal 1979 military and bill, eliminates the language in existing U.S. law mandating the embargo. That language, adopted in 1975, subsequently was modified to allow Turkish purchases of U.S. military equipment of up to $175 million a year.

The amendment adopted yesterday substitutes guideline language on "U.S. policy and procedure regarding Cyprus, Greece and Turkey." It states that U.S. policy should continue "to accord high priority" to inducing Turkey, which still occupies roughly 38 percent of Cyprus, to withdraw from the island in accordance with U.N. resolutions.

It also calls for assisting the island's dominant Greek and minority Turkish communities to negotiate a "just settlement" of their differences that will avoid future provocations and restore the island's sovereignty.

Lastly, the amendment instructs the president to report to the House and the Senate at 60-day intervals on progress toward a Cyprus settlement. It requires the president, in making any requests for arms transfers to Turkey, Greece or Cyprus, to certify to Congress that the policy goals spelled out in the amendment are being achieved.

McGovern, who originated the compromise idea, argued during the debate preceding the vote that the amendment would permit Congress to see whether Turkey, which considers the embargo an insult, will respond to its repeal in a positive fashion.

He added that if Congress thinks, after a trial period, that Turkey has not made a good-faith effort to remove its forces from Cyprus, the embargo could be restored in next year's military aid legislation.

That argument, reinforced by Byrd and others, was one of two dominant points hammered at by administration supporters during six hours of debate yesterday.

The other argument centered on the contention that continuation of the embargo would be harmful to U.S. security interests on NATO's southeastern flank. Turkish Prime Minister Bulent Ecevit has said his country will remain in NATO but reduce its commitment to alliance defenses if the embargo continues.

On the other side, advocates of the embargo, led principally by Sens. Paul S. Sarbanes (D-Md.), Thomas F. Eagleton (D-Mo.) and Claiborne Pell (D-R.I.), argued that repeal would set a dangerous and immoral precedent by allowing a country to violate restrictions in U.S. law against using American-supplied weapons for aggressive purposes.

In the end, though, the compromise, coupled with an aggressive lobbying effort by the administration, gave the repeal drive a comfortable margin. The final vote also showed an unusually erratic pattern, with Democratic and Republican factions splitting sharply.