Egyptian President Anwar Sadat gave his support today to Israel's demand the Syrian armed forces withdraw from Lebanon and blamed Syrian President Hafez Assad for the turmoil there.

Sadat, speaking after a 90-minute meeting with Israeli Prime Minister Menachem Begin in this southern Sinai resort town near Sharm al-Sheikh, their first such talk in 18 months, said Assad stirred up hostilities in Lebanon with the motive of diverting attention from political opposition at home.

"The whole thing started by Assad was to create a greater Syria. Now the motive is to divert attention from the civil war inside Syria and to prolong his stay as president. If this is his target, he will not ask for war, because it will remove him at once," the Egyptian president said, as Begin, sitting next to him in the airport news conference, nodded his approval.

"My view is that the Syrian forces should withdraw from Lebanon," Sadat said, in his first public suggestion that the 30,000-man Syrian peacekeeping force that entered Lebanon six years ago should leave.

Coinciding with the two leaders' extraordinary display of agreement on wide-ranging issues, reached on the eve of the 14th anniversary of the 1967 Six-Day War between their two countries, the White House announced in Washington that President Reagan has invited Sadat and the Israeli prime minister to meet with him separately in early August. The Israeli invitation will be extended to the winner of the June 30 parliamentary elections in Israeli.

Sadat and Begin appeared to differ on one substantive point -- the continued Israeli air and ground strikes against Palestinian guerrilla positions in Lebanon. Sadat said he asked Begin to order a halt to the attacks, but Begin insisted they are necessary for Israeli's self-defense.

Begin said he did agree to a request by the Egyptian president to give U.S. special envoy Philip C. Habib more time to resolve the Syrian-Israeli confrontation through diplomatic means before Israel attacks the Syrian surface-to-air missile batteries that were deployed in Lebanon on April 29.

In Washington, the State Department announced today that Habib will depart for the Middle East on Friday to resume his shuttle diplomacy mission.

The missiles were placed there the day after Israeli jets shot down two Syrian helicopters used in support of Syrian forces attacking Israeli-backed Lebanese Christian militias in the Sanin mountain range.

Begin said that as a result of today's talks, he would meet again with Sadat next month in Alexandria, assuming he is reelected.

From their remarks afterward, it was obvious that today's meeting dealt primarily with the Lebanese crisis, apparently as an effort to dispel the risk of misunderstanding between Egypt and Israel should the diplomatic efforts collapse and Israel decides on military action.

Both leaders referred to a need to restore the delicate balance of Israel, Lebanese and Syrian policy interests in Lebanon to the status quo before April 28, and the linchpin of that consensus appeared to be Sadat's advocacy of a Syrian withdrawal.

When asked whether he would approve of Israeli strikes against the missiles in Lebanon if Habib's mission fails, Sadat sidestepped the question, saying, "All I am asking my friend, Prime Minister Begin, is to give ample time to the efforts by all parties concerned."

At another point, the Egyptian leader said, "Since Camp David, now about three years, dramatic changes have taken place in the area we live in.But only one fact prevails. This fact is Camp David, the treaty between Egypt and Israel."

The leader said they did not discuss proposed autonomy for the occupied West Bank and Gaza Strip, the status of Jerusalem or the proposed multinational peacekeeping force for the Sinai when the last third of the peninsula is returned to Egypt next April.

Begin said, however, that he and Sadat had decided on "serious solutions" on other issues, which he would not define. Israeli sources said later that Begin was referring to bilateral agreements, including trade and tourism.

"This day, the fourth of June, 1981, will be noted as one of the good days in the life of my friend, President Sadat, and my life and the history of the nations," Begin said. He said he and Sadat renewed their pledge "never to raise arms against each other," while Sadat told the press conference, "We have pledged together that the October [1973] war will be the last war."

The two leaders lunched at a cliff-top restaurant in Ophira, the Israeli-named town near this Red Sea bay in view of the Straits of Tiran, while about 150 Israeli residents protested the scheduled turnover of the remaining portion of the Sinai.

Despite unusually tight security in the entire area, a busload of Jewish settlers from Yamit, in northwestern Sinai, managed to gain a foothold in a beach adjacent to the White Elephant discotheque, where Sadat and Begin held their discussions.

Suddenly unfolding placards, the settlers approached the meeting place, evading barbed-wire fencing by wading into the water, but were driven back by about two dozen stick-wielding soldiers.

Resident of Ophira, who are also demanding higher compensation offers from the Israeli government, were for the most part prevented from getting near the meeting place.

In a meeting with a representative delegation of the settlers, however, Sadat made it clear they would not be allowed to remain in their homes and businesses during the April turnover.

"This area will be returned clean with nobody in it. . . I am responsible for 42 million Egyptians, and you are only 120 families," the Ophira residents quoted Sadat as saying. They said he promised, however, to "cooperate" after the evacuation.

Jonathan Randal of The Washington Post repeated from Beirut:

Middle East watchers assessed the Sinai meeting as formally supporting the Habib mission while raising Syrian suspicions that could frustrate practical steps necessary for its success. Counterbalancing Sadat's suggestion that Israel give Habib more time was his demand that Syria withdraw its 22,000-man peacekeeping force in Lebanon.

To date, the most visible accomplishment of the Habib mission has been to reestablish American influence with the Syrian government. At no time has any American source suggested that Habib is seeking the withdrawal of the Syrian force, which has formal Arab League backing. The main thrust of the Habib mission now is said to be to involve Saudi Arabia and other conservative Arab states in buttressing the Syrian force -- in an effort to defuse the Middle East missile crisis -- rather than ending its mandate and risking a return to open-ended violence.

Whatever private misgivings Lebanese President Elias Sarkis may have about the Syrian role in Lebanon, he has never shown any desire to abrogate the peacekeeping force. Any such action would meet Christian militia demands, but run counter to the wishes of the Moslem majority.