JERUSALEM, FEB. 1 -- The names are different and the focus this time is on Iraq rather than Iran, but Israeli efforts to put to rest the Iraqi pipeline affair are haunted by memories of the Iran-contra scandal, which the new affair echoes in several ways.

Then, as now, Israeli leader Shimon Peres and a small group of Cabinet ministers gave a green light to cooperation with a group of eager American officials and middlemen venturing into an area outside their usual purview.

The characters' names then were McFarlane, Poindexter, North and Secord; now they are Meese and Wallach.

In both instances, a group of Israeli businessmen who have close ties to Peres, and who are at home operating in the shadows of intelligence and security affairs, lent their services as go-betweens who developed a financial as well as personal stake in the matter. Then they were Yaacov Nimrodi and Al Schwimmer; now it is Bruce Rappaport, a multimillionaire oilman based in Geneva.

And now, as then, the matter has become a cause celebre -- more because of domestic American politics and the momentum that potential scandals acquire in Washington -- and Israeli officials sit back and wonder why the Americans are doing this to them, and to themselves.

The controversy was triggered last week when the Los Angeles Times disclosed that independent counsel James C. McKay is investigating whether the pipeline's financial backers, led by Rappaport and advised by American lawyer E. Bob Wallach, had proposed payments to Peres or his Labor Party to secure his support for the project.

McKay is focusing on a 1985 memo to Attorney General Edwin Meese III from Wallach, a close friend and former lawyer of Meese, in which Wallach allegedly discussed the possibility of such payments. Federal law provides for Meese, the country's top law enforcement official, to take action against such a plan should he become aware of it.

Peres -- who was then prime minister and is now foreign minister -- and Rappaport have emphatically denied any such scheme was ever hatched or discussed or that any money or anything of value was ever offered or given to Peres or his party.

The pipeline controversy, nevertheless, illustrates several important themes here.

The fact that Israel was prepared to give guarantees that it would not sabotage the $1 billion project indicates anew the ambivalence with which the Israelis regard both sides in the Persian Gulf war. At the same time they were giving the go-ahead to Iraq, Israeli officials were tacitly approving the sale of arms and military spare parts to Iran.

The project also makes clear that even countries supposedly in a state of war with Israel -- in this case Iraq and Jordan, through which the pipeline would have run -- consider it vital to get Israeli approval for major projects that might affect the delicate balance of power in the Middle East.

But most intriguing, the affair illustrates anew the almost fatal attraction between the enterprising swashbucklers who have been drawn to the Reagan administration and the plucky, can-do Israelis led by Shimon Peres, a man who, as one associate puts it, "never likes to say no."

Peres and the Reagan administration are a match made in heaven, contend some observers here, including diplomats and journalists.

Administration officials have always admired Peres' defense background -- his air of realpolitik, his penchant for intelligence operations and his ability to keep a secret. To them he is the epitome of the tough, security-minded Israeli who cuts through red tape and likes to gamble.

Peres in turn has felt obligated to the Reagan administration for the financial aid it has provided Israel and for its general diplomatic support. Peres has described Israel's role in the Iran affair as "doing a favor for a friend," and the same could be said to apply to the pipeline proposal.

When it comes to helping the United States, Peres appears to ask few questions. When then-national security adviser Robert McFarlane told him that the arms-for-hostages exchange with Iran had President Reagan's approval in 1985, Peres never raised the matter with Secretary of State George P. Shultz, the man in charge of foreign policy.

Similarly, when Meese contacted Peres about the pipeline that same year, Peres presumed that Meese, as "a competent official of the United States government," was representing the government and acted accordingly, according to informed sources here.

At first glance, it might appear contradictory that Israel would give the green light for the Iraqi project while tilting toward Iran in their war, but analysts here say differently.

Israel's goal was to maintain the balance between the two countries because it saw a continuation of the war as being in its best interests, according to David Menashri, a Tel Aviv University historian and expert on the conflict. Peres reportedly had a second goal: aiding Jordan's King Hussein, a moderate Arab leader who stood to benefit economically from the vast project and strategically from having a potential new lever over his militarily powerful neighbor in Baghdad. "There was nothing here that was out of line with basic Israeli policy," says Menashri.

The pipeline affair again raises the question in the Israeli press and among diplomats of whether Israel under Peres has been too willing to act as an American agent. In the Iran arms affair, critics contend, Israel served as a clandestine arm of the U.S. government, one not subject to U.S. legal constraints and therefore free to conduct an operation the Pentagon and CIA felt uneasy about.

This time Israel appeared prepared to give secret guarantees it would not sabotage the pipeline project. Again Israeli middlemen with suspected ties to the Mossad spy agency were playing key roles.

Many Israelis say they do not like playing the role of America's secret agent, but few see much choice. Israel, they say, is a small power in a tough neighborhood and has to rely on an alliance with a superpower such as the United States to survive.