Israel's Cabinet, in a move that appeared to be designed to defuse a major political controversy surrounding the chief of the secret security service, named a new attorney general today to replace Yitzhak Zamir.

Zamir, who had pressed for a police investigation of charges that the security head attempted to cover up the 1984 beating deaths of two captured Arab hijackers, had said in February that he wanted to resign but would remain in the job until a successor was named.

After hearing a report by Prime Minister Shimon Peres on the allegations against Avraham Shalom, chief of the Shin Bet, the secret security service, the Cabinet named a Tel Aviv judge, Yosef Harish, 62, to replace Zamir as of Wednesday.

Harish said on state-run Israeli television tonight that he regarded a discussion between himself and the government on the principle of prosecuting the security chief as essential. But he added, "I think it should be held behind closed doors and shouldn't be publicized."

In sharp contrast to Zamir's public insistence that the rule of law should take precedence over security considerations, Harish added, "The time has come to fold up the tents and get this back into the corridors, where a proper discussion can take place on such a matter of principle."

Asked whether all aspects of the matter of principle should be debated in secret, Harish replied, "For certain, yes. Not necessarily in a commission of inquiry" -- a closed form of investigation favored by some Cabinet members.

Harish also indicated that he will not hurry a decision on the matter. When asked by Israeli radio whether he had been asked to express an opinion about the Shin Bet case before his appointment, he said, "Absolutely not. Even if I had been, I would not have been able or prepared to express an opinion on a subject I have not studied."

Until today, no names of nominees had been put forward publicly by Cabinet ministers, and the government's decision appeared intended to accelerate Zamir's departure in order to dampen the crisis atmosphere surrounding his insistence that Shalom be investigated and possibly prosecuted for allegedly ordering the fatal pistol-whipping of the Arab prisoners and for the alleged suppression of evidence and suborning of witnesses.

Zamir, attorney general for seven years, said he was not upset by the timing of Harish's appointment. "Personally, I'm very relieved," he said. "I've had enough trouble." He added that he believed the affair "will be handled properly by Judge Harish. . . . He's a good lawyer and a good man, and I believe he will make a good attorney general."

The government sought to dispel the notion that Harish's appointment was designed to suppress disclosure of the facts in the case or to protect Peres or Foreign Minister Yitzhak Shamir, who was prime minister at the time of the incident, from charges that they also participated in a cover-up of the killings. More than six months ago, Peres rejected pleas by three of Shalom's Shin Bet deputies that Shalom be investigated for obstructing justice.

Initially the Army had announced that all four Arab hijackers had been killed during the storming of the bus in the Gaza Strip in April 1984. But following the publication of a photograph showing one of them being led away in handcuffs, two special inquiry commissions ruled that two of the hijackers had been beaten to death during interrogation in a nearby field.

Cabinet Secretary Yosi Beilin today said there was "no connection at all" between the naming of a successor to Zamir and the controversy surrounding his demand for an investigation of Shalom. "The attorney general decided four months ago to resign and said the moment someone else should be found to replace him, he would resign, which was done today," Beilin said.

A Cabinet communique said Peres "expressed his appreciation to Prof. Zamir for long and excellent service, his courage in office and his activities according to the dictates of his conscience." It said, however, that Peres' report on the Shin Bet affair was classified and that only Peres and aides he authorizes will be permitted to make public comments on the affair.

Peres and several other ministers were known to oppose turning the case over to the national police but instead giving it to a special judicial commission that would hold closed hearings and keep testimony secret. Such a procedure would not require the suspension of Shalom, as would a police inquiry.

Peres has rejected calls to end the controversy by suspending Shalom, saying it would weaken the security services by tainting its chief without giving him an opportunity to defend himself.

Beilin said that if the government decided on a judicial inquiry, it would be with the approval of Harish, even though that approval is not legally required.

The minister most critical of the government's handling of the case until now, Communications Minister Amnon Rubenstein of the Shinui Party, said in an interview that he was satisfied with Harish's appointment.

Rubenstein said Harish is "a great jurist and has personal integrity and complete independence, and I'm sure he will continue the tradition of independent attorney generals who do not take orders from any political body." He called the Shalom case "a tragedy in which almost everybody has his own justness, his own rights, his own claim to his case and to his conscience."

Harish was born in Jerusalem and, before Israeli independence, served in the British Army in Palestine and then in the Jewish underground army, the Hagana -- for which he was imprisoned by Britain. He is an Army reserve colonel and serves on the Military Appeals Court.

In the 1970s, he drew attention by overturning a death sentence given an Arab terrorist who was wounded by his own bomb, noting that the defendant had not injured anyone but himself.