Ariel Sharon agreed today to give up his post as Israel's defense minister on Monday, but with the backing of Prime Minister Menachem Begin and other political allies he will attempt to remain as a member of the Israeli Cabinet in another capacity.

Climaxing four days of tumult set off by the report of the commission that investigated the Beirut massacre of Palestinian refugees, which called for his ouster from office, Sharon informed Begin of his decision in a telephone call this morning.

Moshe Arens, the Israeli ambassador to the United States who has previously turned down the powerful post of defense minister, was reported to be Begin's choice to succeed Sharon. There was speculation, however, that Arens would not accept the job if the domineering Sharon were to remain in the Cabinet, one of several factors that made the proposed Cabinet shuffle aimed at preserving a place in the government for the outgoing defense minister less than a certainty.

Sharon, appearing for a speech in Tel Aviv, told The Associated Press: "There was a reshuffle of portfolios, and that's the end of the problem. I am still in the Cabinet. Begin did not fire me."

Shifting Sharon to the post of minister without portfolio in the Cabinet would require the approval of the Israeli Knesset (parliament). In the currently heated atmosphere in the country, such a move would undoubtedly set off a storm of protest by Sharon's legion of opponents whose bitterness had been heightened by the explosion outside Begin's office last night that killed an antigovernment demonstrator from Israel's Peace Now movement.

The inquiry commission also recommended that Maj. Gen. Yehoshua Saguy be removed as chief of military intelligence and that Brig. Gen. Amos Yaron, who was commander of all Israeli forces in Beirut at the time of the massacre, be demoted from field command for at least three years.

There was no immediate action against the two officers, but Army Chief of Staff Lt. Gen. Rafael Eitan, himself severely censured in the report, made clear that the commission's recommendations as adopted by the Cabinet will be carried out by the Army.

"The military echelon will carry out the decisions of the government as is customary in a functioning democracy," Eitan said. "The Israel Defense Forces will learn the lesson of the inquiry commission's findings."

Jerusalem police said today that they still had no suspects in the bombing incident, said by authorities to have been caused by a hand grenade that exploded near the Peace Now demonstrators. During the day police detained for questioning but later released Rabbi Meir Kahane, a Brooklyn-born, militant Jewish nationalist and leader of a group that advocates the forcible expulsion of the Palestinian Arabs from the occupied West Bank and Gaza Strip.

The explosion, which stunned Israelis and brought angry charges today that the Begin government has fostered an atmosphere of political intolerance in the country, occurred as the Cabinet was debating the 108-page report on last September's massacre of hundreds of Palestinian refugees by Lebanese Christian militiamen in Israeli-occupied West Beirut. With only Sharon dissenting, the Cabinet late last night voted 16 to 1 to adopt the report and its recommendations, effectively isolating Sharon and dooming his last-ditch effort to retain the Defense Ministry post.

The 54-year-old Sharon is scheduled formally to leave the position he has occupied since 1981 on Monday after meeting with the Israeli Army's general staff. He told the Israel Bar Association in Tel Aviv today that he "categorically rejected" the inquiry board's conclusion that Israel bears clear "indirect responsibility" for the massacre of the refugees.

Sharon said that his rejection of that finding of guilt, "as a man, a Jew, an Israeli, a soldier and a minister," was the sole basis for his opposition to adoption of the commission's report. He predicted that the commission's findings would be used against Israel by its enemies and become "a mark of Cain on the forehead of us all."

In the speech, Sharon also had some parting shots for the United States and President Reagan's Middle East peace plan, which calls for Israel to give up large parts of the West Bank as part of an overall peace settlement. Accusing Americans of not understanding Israel, Sharon said he would forever remain opposed to the Reagan plan and predicted that Israel will never accept it.

Using the Cabinet shuffle as a means to preserve a place in the government for Sharon was said to have been proposed by Begin during last night's Cabinet meeting, but it was not accepted by Sharon until today. Under the plan, Sharon will not formally resign as defense minister. Instead, on Monday, Begin is expected to announce to the Knesset for its ratification a shift in Cabinet responsibilities, with the prime minister temporarily assuming the defense minister's duties and Sharon proposed as minister without portfolio.

There is a section in Israeli law that allows such a shift with Knesset approval, but it is not the section cited by the inquiry board's report, a factor that is bound to increase charges that Begin and Sharon are attempting to evade the conclusions of the investigation into the massacre. The commission called on Sharon to resign and, citing another section of Israeli law on the powers of a prime minister to fire other ministers, said that if he refused Begin should dismiss him.

Mordechai Wirshubski, a member of the small, left of center Shinui Party, said allowing Sharon to remain in the Cabinet would "make a mockery" of the commission's recommendations. Shinui leaders said they will bring a motion of no confidence in the government before the Knesset next week as a result of the proposed maneuver.

It was not clear, however, whether an attempt to bring down the Begin government over the issue and force new elections as a result would have strong support from the main opposition Labor Party. The party's leaders, who this week limited their public comments to a call for full implementation of the commission report, are to meet Saturday night to map their strategy.

The Labor Party, acutely aware of public opinion polls that show Begin still in a dominant political position in the country, does not appear eager to cooperate in any move that would force a test of electoral strength between it and Begin's ruling Likud Bloc.

Ambassador Arens, mentioned as Sharon's possible successor, opposed the Egyptian-Israeli peace treaty and is viewed as being as hawkish as Begin and Sharon on the key issue of the West Bank and Gaza Strip. While he might oppose sharing a Cabinet seat with his predecessor, Arens is known to have political ambitions in Israel that are unlikely to be fulfilled so long as he is serving in a distant, albeit important, diplomatic post.

Begin met this morning with leaders of the Likud and received their predictable unanimous approval of last night's Cabinet vote. Following the meeting, Energy Minister Yitzhak Modai told reporters, "If he Sharon wishes, he can stay in the Cabinet. I am sure the government will accept him gladly. The decision is his."

Others, however, clearly will not accept such a move without a fight. Early this morning, leaders of the Peace Now movement vowed that they "will not tolerate any arrangement which will permit Mr. Sharon to continue to serve in any capacity in the Cabinet."

The defense minister is second in importance and authority only to the prime minister in the Israeli government and the loss of that position will strip Sharon of much of his power base. But if he manages to remain in the Cabinet, it remains to be seen whether he will find a new source of power such as he exercised previously as agriculture minister.

In that relatively unimportant post, Sharon became the driving force behind Israeli settlement in the West Bank, winning the undying loyalty of those who oppose surrendering any portion of the occupied territory for any reason.