The Israeli Cabinet tonight rebuffed a demand by the United States that Israeli forces withdraw immediately from West Beirut, declaring that its troops will leave the city only when, in Israel's judgment, the Lebanese Army is able to take over for them.

The Cabinet statement, adopted unanimously during a four-hour special meeting that ended just before midnight, appeared to be phrased so as not to be an outright rejection of the American demand. But it made highly uncertain a prompt withdrawal by Israeli troops, leaving open the question of when they will pull back from the positions they took in the city following the assassination Tuesday of Lebanese president-elect Bashir Gemayel.

Israeli Defense Minister Ariel Sharon was earlier reported by Israeli television to be adamantly against immediate withdrawal. He was quoted as telling U.S. special envoy Morris Draper, "We have saved Lebanon again for you."

The Cabinet statement charged the Palestine Liberation Organization with "blatantly violating" the evacuation agreement negotiated by U.S. special envoy Philip C. Habib by leaving behind in West Beirut "about 2,000 terrorists, equipped with modern and heavy weapons."

The statement did not say what the count of PLO fighters in Beirut was based on, nor did it say what, if anything, Israel intends to do about their alleged presence in the city.

The Cabinet communique said Israeli forces entered West Beirut only to prevent "violence, bloodshed and anarchy," and added that "this danger was indeed averted."

"The Israeli government will instruct the Israeli Defense Forces to evacuate these positions when the Lebanese Army will be ready to assume control over them, in coordination with the IDF, in order to ensure public order and security," the Cabinet statement said.

The communique appeared to be ambiguously worded deliberately and left open a number of questions, among them who will decide when the weak Lebanese Army is ready to take over control of the city.

Earlier today Prime Minister Menachem Begin had personally defended Israel's thrust into West Beirut, saying it was justified because the Palestinians had violated the agreement governing their withdrawal from the city.

Begin told a political meeting in Tel Aviv that in the last two days it had become clear to Israel that the PLO had left a large number of armed guerrillas behind in Beirut after the bulk of its forces had been evacuated, and in so doing had "deceived Israel, Lebanon and the United States."

"Not all the terrorists pulled out," Begin said. "They gave a commitment that all of them would leave and not only to us but to Philip Habib. They left a sizable number of terrorists and their weapons."

When Israeli forces began to move into West Beirut early yesterday morning, they said their only purpose was to prevent chaos and possible widespread bloodshed in the aftermath of the assassination of Lebanese president-elect Bashir Gemayel.

The Israeli forces, according to reports here, encountered unexpectedly strong resistance, and today officials began to stress that the presence of a large number of Palestinian guerrillas in the city was further justification for the Israeli move.

Officials said the number of PLO fighters in Beirut was "in the hundreds," but they were not more specific.

Israeli officials said throughout the PLO evacuation that they assumed some guerrillas would attempt to remain behind in Beirut, but at the time they seemed unconcerned about that possibility so long as the withdrawal proceeded according to schedule.

Tonight's Cabinet meeting was originally scheduled earlier today amid reports that some government ministers were angry that they had not been consulted before the decision to order the Army into West Beirut. But before the meeting convened, Israel was informed of the demand by the Reagan administration that the Israeli forces withdraw.

The decision to advance into the city following the assassination of Gemayel was reportedly made late Tuesday night by Begin, Sharon and Foreign Minister Yitzhak Shamir.

The independent newspaper Haaretz today quoted some ministers as calling the action by the three men without consulting the full Cabinet an "unprecedented scandal." According to the newspaper, the ministers accused Sharon of using the Gemayel assassination as a pretext to accomplish what the Cabinet had prevented him from doing in the past -- moving in on West Beirut to clear it of any remaining PLO fighters and other armed leftist factions.

Meanwhile, the Israeli military command announced that as of late this morning Israeli forces were "in control of all key points in Beirut."

The announcement appealed to Beirut citizens "to return to normal activity" and called on "all terrorists and other armed persons to lay down their arms."

Throughout the day, Israeli officials insisted that their forces entered Beirut only to prevent anarchy following Gemayel's assassination. But they maintained the situation in Beirut remained "very unclear" and they were unable to say how or when the Israeli Army would leave the Lebanese capital.

The officials said that until the Gemayel assassination, Israel was satisfied with the slow progress of the Lebanese Army in taking control of West Beirut. But they said the death of Lebanon's president-elect presented an entirely new situation that had required rapid action by Israel.

"Had the process of restoring the Lebanese government continued, we would have left the job to the Lebanese Army," said an official who asked not to be identified. Now, he added, "we start the process over again."