It was the day before the Senate Foreign Relations Committee was to vote on the president's "package deal" of warplane sales to the Middle East, and Jimmy Carter was unhappy.

Two important senators - Frank Church (D-Idaho) and Jacob K. Javits (R-N.Y.) - had just rejected a compromise plan the president had offered them a day earlier. Carter proposed selling Israel 20 additional F15s, and providing the Senate with written assurance that Saudi Arabia would not equip its 60 F15s with offensive weapons or base them near Israel.

The White House thought Church and Javits had bought this bargain, but on that Wednesday, May 10, they said they couldn't swallow it. (Both senators say they never gave any commitments.)

Did we misplay it: Carter asked his aides. Did we offer the compromise too soon? The answer, he was told, was no. The timing had been crucial to win over Sen. Howard H. Baker Jr. of Tennessee, the minority leader and an important Republican on the Foreign Relations Committee. The White House could afford to lose Church and Javits if they had Baker.Baker was key.

Despite that moment of uneasiness - and one or tow others later on - Carter's political counselors were right. Baker was key - as he had been on the Panama Canal vote in April. The Foreign Relations Committee deadlocked, 8 to 8, on the plane sales and voted to send the issue on the floor, but there were more than enough votes for the sales there. The final tally was 54 to 44, but 60 senators had said they would vote "aye" if they were needed. Baker's Republicans voted 26 to 11 with the president.

Success on this vote was something of a first for Carter's White House. It was the first time the administration had plotted a sophisticated strategy to win congressional approval for a controversial policy, stuck closely to the strategy throughout a tough fight and ended up victorious.

The victory was not cheap, and not without negative repercussions. Carter depended heavily on Republicans and Democratic conservatives, and he aroused many American friends of Israel to an emotional state of outrage. But the White House was clearly pleased to pay that price for a win it viewed as crucial to its Mideast policy, and useful to improve its political image at home.

"It wasn't a bad shootout for the gang that can't shoot straight," quipped one senior official involved in the fight.

Reviewing it all in conversations yesterday, several administration officials described the plane sales fight as Congress's first confrontation with some specific changes that have taken place in the Middle East in the last few years," as one put in. Sen. Abraham A. Ribicoff (D-Conn.), another crucial supporter of the plane sales, called this facing up to "new realities."

Until this vote the Congress had not faced an issue that so clearly reflected the new facts about Saudi Arabian oil and dollar power ad the repercussin of Egyptian President Anwar Sadat's peace initiative. Congress unanswering support for Israel in the past had always been direct and a relatively simple matter. In pressing the package deal, Carter removed the simplicity.

The idea of a package is said to have first come up in a memo written to Carter last year by his chief congressional lobbyist, Frank Moore. This year the president himself is described as the official who revived it, and the idea was worked out in meetings attended by Hamilton Jordon, Carter's principal aide, Moore, Zbigniew Brzezinski, the national security affairs adviser, Secretary of State Cyrus R. Vance and Defense Secretary Harold Brown.

The original notion struck all in the government as a practical one. Israel's new prime minister, MenachemBegin, has pressed the United Stated repeatedly to make good on commitments made by the Ford administration to provide advanced warplanes. In Saudi Arabia last January, Carter and his associates were smitten by the fervor with which Saudi leaders asked for the warplanes the Ford administration had offered them. And Carter was anxious to do something positive for Sadat to "reward" his peace initiative.

Early White House discussions of the package led to an inquiry from Brzezinski's office to the State Department's legal adviser and to the Department of Justice: Under the arms sale act that gives Congress a veto over major arms transfers, could the president submit a "package" of sales to different countires in one proposal to Congress?

The legal answer was no - each sale had to be submitted separately. But this did not rule out a political decision to treat the sales as a package.

Early soundings on Capitol Hill after Carter returned from his trip to Saudi Arabia, Egypt and other countries convinced the administration that there would be serious opposition from Israel's supporters to selling advnced weapons to Saudi Arabia and perhaps to Egypt, too. So the political decision to make a package was taken.

The State Department was uncomfortable with this idea, and urged that the administration downplay the idea. Officials at State feared the legal problems, and the possibility of arousing congressional emotions.

But this caution was overruled. In testimony to the House Committee on International relations on Feb. 25, Vance laid out the administration's terms bluntly: all three sales, he said, or none.

This was probably the crucial moment in the entire fight. The notion of an imposed package made Carter's eventual victory possible - first because it complicated the issue for members of Congress who were used to providing whatever arms Israel said it needed, and second because Carter could later offer a tactical "compromise" on the package issue at a delicate moment.

(State Department officials who originally disliked the package idea now say it worked out splendidly.)

But the package would only work if the Israelis would agree not to meddle with it. At any point in the fight, administration officials knew, Israel might decide to withdraw its request for American planes, unraveling the package and leaving it extremely vulnerable.

This left Israel in an agonizing position. On one hand the Israelis really did want the 75 F16s and 15 F15s they were offered in the package. (Indeed, they wanted 150 F16s.) They viewed these as crucial to maintain Israeli air superiority in the Mideast in the mid-1980s. And they felt they had a commitment for these planes from the Ford administration.

But Israel did not like the idea of a package which made sales of arms to it dependent on congressional approval for sales to its potential enemies. This idea was a painful symbol of America's changing relationships with the Arab states - and for many Israelis a terrifying symbol. Could they no longer depend on a special relationship with America?

Israel's friends in Washington also disliked the idea. In early March they spoke confidently of their ability to force the White House to delay the package.If that failed - which members of the so-called Israeli lobby doubted - they said confidently that they had enough votes to defeat the proposed Saudi sale in both houses. "Let the president emforce his package after we beat the Saudi deal," said one member of the House.

But this was over optimistic. By mid-April, the White House's congressional liaison staff had canvassed a good range of opinion in both chambers and found support for the package deal was even stronger than they had hoped. They learned, for example, that Ribicoff, long known as one of Israel's staunchest friends, was favorably disposed to the sales. On April 28, the White House formally submitted the sales to Congress; the House and Senate had 30 days to act, and both chambers had to act negatively to block any or all of the sales.

If Israel ever flirted seriously with the idea of withdrawing its request for planes to unravel the package, it was during the last week of April. Departing from Israel on a trip to the United States, Foreign Minister Moshe Dayan was quoted as saying Israel might prefer no planes to the whole package deal.

When Dayan then arrived in Washington, Vance took him aside almost at once and spoke to him sternly, informed sources report. The secretary told Dayan unequivocally that Israel could not be on both sides of this issue - either it wanted its planes or it didn't. Dayan said Israel wanted its planes. He reiterated that position on a U.S. television interview.

But members of the Israeli lobby in Washington told reporters and members of Congress that really, Israel opposed the whole package. The Israeli embassy here would not say that in so many words, but spokesmen there said repeatedly that Israel opposed the package deal. Did that mean it preferred no sales to all three? No, the embassy wouldn't say that. The ambiguity was deliberate, if obvious.

In Congress there was always great interest in avoiding any showdown on the sales. Members all knew how hard the Israeli lobby and Jewish organizations were woking to defeat the idea, and no member of Congress welcomes a vote that might put him against those influential forces.

Ribicoff was anxious for compromise. In mid-April he heard Baker on a television program propose several possible compromises in the administration plan, and Ribicoff liked what he heard. He told Baker his ideas could be the basis for a compromise plan that might head off a floor fight.

Baker agreed to wrok with Ribicoff, Javits, Church and others to see if the administration would compromise. He eventually proposed the 20 additional F15s for Israel, plus the assurances about Saudi use of its F15s. Carter agreed.

Baker was described as confident that Javits would endorse that compromise, and at a breakfast meeting with Vance last week, he was said to ing if Israel could also get more F16s. In the end Javits rejected the White House gesture but Baker stuck with it.

Church personally tried to sell the compromise for about a day, but found he couldn't get much new support for it on the Foreign Relations Committee. Also, he said yesterday, he learned from the Senate parnamentarian that if the committee voted against the arms sales, any senator could still call the issue up before the Senate under the terms of the arms sales act.

Church had hoped a compromise that satisfied the committee would kill the issue and head off any floor vote, but when he discovered it wouldn't, his interest in compromise waned, Church said. He decided not to support Carter's proposal.

his reversal stunned Robert C. Byrd (D.W. Va.), the majority leader, Ribicoff and some members of the administration. Church said yesterday he may have made a mistake by trying to sell the compromise to other senators, but he added that he never gave an explicit commitment to support it. Administration officials agreed.

On Monday morning, just hours before the Senate's final vote, the president's aides briefly lost their confidence. For a few horrible minutes they contemplated the possibility that last - minute lobbying had eaten away their support Sens. William Hathaway (D-Maine) and Gary Hart (D-Colo.), who they had counted as supporters, indicated they would oppose the package.

But before panic took hold the news began to change. John Culver (D-Iowa) and Dale Bumpers (D-Ark.) joined the administration cause, as did numerous Republicans. By midday the administration could count 51 firm votes.

What made their victory possible? Administration officials offered lots of reasons: the success of the package idea, the original strategy, Begin's intransigent public positions, the effectiveness of the new "Arab lobby" in Washington, the Israeli invasion of Lebanon, Saudi Arabia's smooth diplomacy, Anwar Sadat's good reputation.

Sen. John Stennis of Mississippi had a one-word answer that may have summed it all up: "Oil."