Israeli Defense Minister Ezer Weizman turned up unexpectedly in Egypt today. After meeting in Ismailia with President Anwar Sadat, he flew off to a northern air base for five hours of talks with War Minister Abdel Ghani Gamasy.

The surprise mission by Weizman - the highest ranking Israeli ever to visit Egypt - came as Sadat and Prime Minister Menahem Begin prepared for their pivotal Christmas Day summit.

An official Egyptian announcement tonight said the Israeli defense minister's trip was the result of "a previous agreement between the two sides" to lay the groundwork for Begin's arrival Sunday.

Egyptian officials said that during their lengthy talks, Weizman and Gamasy discussed lines of withdrawal for the Israeli-occupied Sinai.

In Jerusalem, officials said Weizman and the Egyptian leaders discussed the Sinai and "other security problems."

In any case, the leaders of Egypt and Israel have once again taken a step that has caught the world - and most of their countrymen - far off balance.

Even Israeli and Egyptian delegates to the preparatory peace talks, which have been sputtering along here at the Mena House Hotel for nearly a week, seemed surprised by news.

The public announcement of Weizman [WORDS ILLEGIBLE] made over loudspeakers [WORDS ILLEGIBLE] House, seemed designed to emphasize Sadat's determination to do his talks with the Israelis in "the [WORD ILLEGIBLE] and lay to rest the persistent rumors that high-level secret meetings have been taking place.

The official Egyptian statement on the Weizman trip said the Israeli defense minister's first stop was the Suez Canal city of Ismailia, where Sadat has taken up residence in anticipation of Begin's arrival Sunday.

After meeting with Sadat, Weizman and Gamasy then flew to Gianaclis military airfield, about 45 miles south of the Mediterranean port city of Alexandria, where they met for five hours. Weizman planned to spend the night at the air base, a spokesman said. There was no indication he would return to Israel.

Osmana Baz, a member of the Egyptian delegation to the preparatory talks, told reporters tonight that Weizman's visit has "strong links" with the Cairo peace conference.

"We expect big concessions from Israel, particularly after the visit of Begin on Sunday," Bax declared. He offered no reasons for his optimism, however.

Gamasy and Weizman are career military men, but they have sharply different styles and backgrounds. The Egyptian general is reticent, correct, and known for this determination to keep himself and the army out of politics. Weizman, now a civilian is bluff, outspoken, and a politically active figure in Begin's government.

This was apparently their first meeting, since Germany did not accompany Sadat on his trip to Israel last month. Sadat did seek out Weizman on that trip, however, and they agreed that after the recent scare in which the two sides went on alert because of anxiety over unannounced military maneuvers, they should establish some sort of direct contact between the two defense ministries.

The most likely purpose of today's visit, however, was to discuss the military and security implications of various moves that might be made as a result of a negotiated peace settlement.

Such questions as the redeployment of Israeli troops from and within the territories occupied in the 1967 war, the establishment of buffer zones and demilitarized zones and possible limitations on Egyptian troop presence in the Sinai were considered likely topics.

Gamasy has already told an Israeli journalist in a rare interview that he did not believe the Israelis had anything to worry about if they pulled back from the Sinai or the Golan Heights, but that he understood their concerns about the West Bank.

The Weizman talks brought further disarry to the preparatory peace talks, which are in a virtual state of suspended animation while the real decisions are made elsewhere.

The talks were in recess today anyway as the Israeli delegates went to visit Sadat's native village, but the delegates admit that they do not know what to talk about when they resume on Wednesday.

Sources in the delegations said a legal subcommittee has worked out some proposals for an agenda for a possible comprehensive peace conference, but even these have been so generally worded that neither side has found anything to object on.