With only three votes to spare, Prime Minister Menachem Begin's beleaguered Likud coalition government narrowly sqeaked through a no-confidence vote tonight in Israel's parliment.

The vote, 57 to 54, was the narrowest of the dozens of no-confidence motions that have been submitted in the Knesset since Begin was elected in 1977. It seemed certain to weaken further the prime minister's power base and increase significantly the likelihood that a national election will be held earlier than next November, as it is now scheduled.

The political setback came three years to the day after Egyptian President Anwar Sadat made his historic visit to Jerusalem to address the Knesset and start a peace process that put Begin on the road to his major accomplishment as prime minister.

Among his former supporters who voted against Begin on the motion -- which condemned the government for economic policies that have been led to an annual inflation rate of 150 percent -- were former defense minister Ezer Weizman and former foreign minister Moshe Dayan.

In dramatic speech that riveted the attention of the parliament and sent shock waves through the Likud bloc, Weizman, who was Begin's campaign manager in 1977, said the government was making Israelis "fed up with peace."

Dayan said there was an "intolerable gap between the government and the people," and that if there is no immediate improvement in the economy, Israel will have "no political options" in pursuing peace.

The vote was so close that had two Knesset members, Shmuel Flatto-Sharon and Akiva Nof, voted against Begin as they had announced they would, the government would have fallen. Instead, both obstained.

Also, two members of the oppostion Labor Party failed to return from abroad for the vote, which could have spelled the difference, although Foreign Minister Yitzhak Shamir, who was in Europe, also was not present.

Apparently anticipating a close ballot, Begin cut short a visit to the United States and arrived in the parliament barely two hours before voting began. The Likud yesterday beat back a Labor Party maneuver to hold the vote then, when Begin and seven coalition members were out of the country.

Arriving at Ben-Gurion Airport, the prime minister said he was aware of widespread dissatisfaction with inflation, which in October was 11 percent according to the monthly cost of living index.

"I know it is a difficult situation. . . . only i don't know why there should be a kind of despair. We had more difficult moments in the past [that] we overcame. I hope we will overcome this difficulty as well," the prime minister told an airport news conference.

About 40 speakers addressed the occasionally tumultuous Knesset session, some of them calling for Begin's resignation and others urging early elections.

Under Israeli law, a no-confidence vote against the government would force Begin to go to Presdent Yitzhak Navon and ask him to attempt to form a caretaker government, while a subsequent motion to dissolve the Knesset would lead to a national election.

Public opinion polls indicate that if the election were held now, the Labor Party would be swept into office by a large margin, and possibly with a majority. In that case, Labor would not have to seek coalition partners, which traditionally weaken the ruling party's power base.

The most stinging criticism in the debate today came from Weizman, who said he was afraid to face the poor people in Israeli development towns that he visited during the 1977 campaign.

"Every morning you get up, they are saying that peace is a disaster. That because of peace, we have a state of emergency and inflation," Weizman said.

"If you will not do something out of the ordinary, and quickly, the government will fall and with it the Likud" bloc, Weizman said.

Begin, looking tired from his trip, walked into the Knesset chamber just as Weizman was speaking, and listened without emotion as his former political ally denounced the government.

Labor's Gad Yaacobi reminded Begin that years ago Begin, as opposition leader, had called for early elections because, he said, the people had lost faith in the government. He compared the present government to a "lost satellite drifting in space."

Former Begin ally Moshe Shamire, of the rightist Tehiya Party, said the government had "devalued everything, from money to Israel's most sacred principles."