By a close vote of 208 to 205, the House responded to President Carter's appeals yesterday and wrote an end to the controversial 3 1/2-year-old congressional ban on the sale of U.S. arms to Turkey.

The House vote, which followed a similar repeal action by the Senate last week means the Carter administration now will be able to deal with Turkey in seeking a Cyprus solution, free of the embargo restrictions imposed by Congress after Turkey's 1974 invasion of that island republic.

Carter called lifting the embargo "the most important foreign policy issue facing Congress" and had staked his prestige on convincing Congress that the arms ban had failed to spur the withdrawal of Turkish forces and threatened instead to disrupt NATO defenses in the Mediterranean.

But, unlike the vote in the Senate, where the administration won by a lopsided 57 to 42, yesterday's showdown in the House was a cliffhanger right down to the last second of vote counting. In fact, the outcome at first appeared to be a 205-205 tie: but amid the pandemonium that then broke out on the House floor, the advocates of repeal managed to eke out the additional three votes that gave them the victory.

The closeness of vote reflected the bitter opposition in the Greek-American community to Turkey's continued occupation of 38 percent of Cyprus, which has an 80 percent Greek population.

During the intense lobbying and infighting that preceded the vote, supporters of the embargo led by Rep. John Brademas (D-Ind.), the House majority whip, spared no effort to impress the attitude of Greek-American voters on House members, particularly those from urban constituencies.

In the vote, the president actually lost the majority of his own party in the House, with Democratic members voting against the administration's position, 141 to 130. What gave Carter his margin of victory was the support of the Republican members who voted, 78 to 64, to lift the embargo.

The main factor in turning the tide for the administration was a last-minute compromise worked out by House Majority Leader Jim Wright (D-Tex.). In place of the administration's orginal request for an unequivocal repeal of the embargo. Wright succeeded in substituting compromise language paralleling that adopted by the Senate last week.

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

The Wright amendment adopted yesterday will permit Carter to end the embargo as soon as he reports to Congress that Turkey "is acting in good faith to achieve a just and peaceful settlement of the Cyprus problem." In practical terms, that language gives Carter almost unlimited discretionary power to lift the arms ban.

However, the amendment also contains guideline language stressing there should be no "lessening of the U.S. commitment" to a Cyprus solution. It specifies that the goals of such a solution should be in accord with United Nations resolutions calling for the withdrawal of Turkish troops from the island, the resettlement of refugees displaced by the fighting there and assisting the island's Greek and Turkish communities to settle their differences peacefully.

The Wright amendment, in a provision picked up from the Senate's version of the embargo repeal, also instructs the president to report to Congress to 60-day intervals on progress toward a Cyprus settlement. It requires the president, in making any requests for arms transfers to Greece or Turkey, to certify to Congress that they are consistent with the policy goals spelled out in the amendment.

In response, Carter issued a statement last night promising a renewed effort "to press for a just and lasting solution in Cyprus." He called the House vote "a crucial step toward strengthening the vital southern flank of NATO," and added: "It will soon make possible the reopening of our military installations in Turkey."

Following imposition of the embargo, Turkey retaliated by closing most U.S. installations on its territory - bases that the Defense Department regards as vital listening posts for gathering intelligence from the Soviet Union. In addition, Turkish Prime Minister Bulent Ecevit has said that, while his country will remain in NATO, it would reduce further its commitment to alliance defenses if the embargo continues.

Warnings about the importance to U.S. security interests of Turkey's continued friendship were pressed hard by Wright and other supporters of repeal debate preceding yesterday's vote. On the other side, Brademas and those seeking to retain the embargo argued it would be against American principles to allow a country to violate with impunity restrictions in U.S. law against using American-supplied weapons for aggressive purposes.

The pro-embargo forces sought unsuccessfully to win approval for an amendment, offered by Rep. Dante Fascell (D-Fla.), that would have suspended the embargo for one year if Turkey agreed to remove its troops from the Cypriot city of Famagusta, allow its Greek refugee inhabitants to return and turn administration of the city over to the United Nations.

The Fascell proposal originally was worked out by Wright and offered to the White House last Friday as a possible compromise. However, it was rejected by the administration on the grounds that it would not be acceptable to the Turks.

The House also voted yesterday for stricter funding and time restraints on withdrawal of U.S. ground forces from South Korea, and told Carter to consult with Congress on each step of the pullout.

The 279-to-117 vote came on an amendment to the $2.5 billion foreign Rep. Samuel Stratton (D-N.Y.), who said Carter should not be given "a blank check on the whole Korean troop withdrawal matter."