IRANIAN officials contacted in Tehran say the time is ripe for a United Nations-sponsored agreement that would lead to Israel's release of 400 Lebanese and Palestinian prisoners.In return pro-Iranian hostage-takers in Lebanon would release their captives. Several Israeli soldiers held by Lebanese groups would also be freed. By releasing two hostages without getting anything specific in return, Iran is trying to convince Western countries to put pressure on Israel to force it to enter the bargaining and undertake the liberation of the Lebanese and Palestinian prisoners it holds. An official close to President Hashemi Rafsanjani said in a phone interview that his country has nothing to lose in the present process. "If it is successful, it will help us to demonstrate that the United Nations in general, and Mr. Javier Perez de Cuellar in particular, still do have an important role to play in the Middle East," he says. "If Shamir's government refuses the deal, it will show the entire Arab world that there is nothing to gain from a negotiation with the Israelis." Since the 1979 revolution, Iran has opposed any Arab-Israeli peace talks. A European ambassador contacted in Tehran comments, "The Iranians see an occasion to get rid of the burden of the hostages while reviving the role of the United Nations in the region." This ambassador added that Iranian authorities are increasingly dismayed by the way the Middle East is reshaping after the Gulf war and are looking for any opportunity to reinforce the influence of the UN, which they see as a counterweight to US and Israeli influence in the region. This is confirmed by Iranian journalists contacted in Tehran. Soon after Iraq's Aug. 2 invasion of Kuwait last year, Iranian leaders said that Iran was in a no-win situation, and that whatever side it chose it would in the long run be among the losers. "This nightmare is now a reality," one journalist says. "Israel and the United States are definitely becoming the dominant powers in the region and that worries our leaders a lot." Iran is exasperated by stalemated peace talks with Iraq and blames the Security Council for not pressing for full implementation of UN Security Council Resolution 598, which calls for international assistance for reconstruction after the Iran-Iraq war. Iran is asking for $725 billion in aid. "If the UN secretary general succeeds in solving the hostage problem, it will strengthen its hands to tackle other issues in the region like the Iran-Iraq peace process and the general issue of security in the Gulf region," says an Iranian diplomat interviewed in Europe. "This would be a first blow to US influence in the region."