JERUSALEM, SEPT. 14 -- Israel and Hungary signed an agreement today for their first exchange of diplomats in 20 years, continuing a general thaw in relations between the Israelis and the nations of Eastern Europe.

The accord, signed in Berne, Switzerland, fell short of Israel's desire to reestablish full diplomatic ties. It provides for Israel and Hungary to set up interest sections in each other's country, with envoys assigned to represent the interest of each without setting up an actual embassy or holding the rank implied by formal relations.

Diplomatic ties were broken by Hungary in June 1967 in the aftermath of the Six-Day War. The agreement is similar to one reached between Israel and Poland last October to exchange interest sections. Romania is the only East Bloc country to have full diplomatic relations with Israel.

A joint communique made public here and in Budapest said the new agreement was reached "with the intention of promoting economic, commercial, cultural and human relations, and in order to facilitate consular matters between their two countries."

A Foreign Ministry spokesman noted that Hungary has the second-largest Jewish population in Eastern Europe after the Soviet Union.

The spokesman said that an improved Hungarian attitude toward Israel and the Jewish community was evident in the decision to allow the World Jewish Congress to hold its most recent meeting in Budapest in May.

Israeli sources said that this country's interests section in Budapest will be officially attached to the Swiss Embassy, which has been looking after Israeli interests in the absence of Israeli diplomats. Hungary's interest section will be attached to the Swedish Embassy in Tel Aviv.