Israel has agreed in principle that $51 million of its $1.2 billion in U.S. economic aid for fiscal 1986 should be returned to help meet Gramm-Rudman-Hollings budget cuts, and the two governments are discussing how to do it, Israeli officials said yesterday.

Dan Halperin, economic affairs minister of the Israeli Embassy here, said Israel believes that it has no legal obligation to return the money.

But, he said, Prime Minister Shimon Peres' government "has been made aware of the problems that Gramm-Rudman-Hollings pose for the U.S. administration and has agreed in principle to help by volunteering the money."

Halperin said details of "how, when and over what time frame" the payments will be made are being negotiated. He said the most likely method involves Israeli transfer of $51 million, probably in increments over an undetermined period, rather than a deduction from further economic aid Congress might authorize for Israel.

The Gramm-Rudman-Hollings legislation, which aims at reducing the federal deficit, will force the State Department to cut aid to recipient countries by 4.3 percent. Unlike every other country, Israel received its $1.2 billion in fiscal 1986 economic aid at the beginning of the fiscal year under a practice that enables it to benefit from the interest.

That left the Reagan administration $51 million short of meeting the requirements of Gramm-Rudman-Hollings, passed after the money was disbursed. To make up the difference, the administration must get that amount back from Israel or squeeze it out of aid funds for other countries.

Halperin said U.S. officials explained that failure to get the money back from Israel would require cutting fiscal 1986 aid to other countries by an average of 6.5 percent. As a result, Halperin said, Peres and Israeli Finance Minister Yitzhak Modai agreed that "Israel should be responsive to the U.S. request to help resolve the problem."

Other Israeli officials said no agreement has been made about how Gramm-Rudman-Hollings will apply to Israeli aid for fiscal 1987.

The two governments have reached a tentative 1987 agreement to raise military aid from $1.8 billion to $1.9 billion and keep economic aid at $1.2 billion. But U.S. sources have said they expect Israel's fiscal 1987 aid to be frozen at this year's levels or be cut slightly.