JERUSALEM -- The Shin Bet, Israel's legendary internal security service, is suffering the aftershocks of two scandals that have shaken its foundations and lent credence to longstanding Palestinian charges that its agents frequently torture Arab prisoners and perjure themselves in court.

The unwritten code, under which the agency used "unconventional" and at times brutal methods to combat Palestinian resistance and terrorism in the occupied territories, has been shattered. A judicial inquiry into the service's methods of interrogation is under way, as is a police investigation. It is estimated that half of the high command of the organization has quit or been forced to retire in the past year.

Damaged, too, is the Shin Bet's almost sacred reputation as a dedicated and unselfish protector that for 20 years has been Israel's main tool in its war against terrorism.

The catalysts for this crisis were two incidents in which top Shin Bet officials were shown to have abused the vast powers entrusted to them. In one, Shin Bet head Avraham Shalom ordered the killing of two captured Palestinian bus hijackers. When a subsequent cover-up began to unravel, Shalom sought to shift the blame first to an Israeli Army general and ultimately to Prime Minister Yitzhak Shamir.

In the second, senior Shin Bet operatives used illegal interrogation techniques -- cold showers, sleep deprivation and blackmail threats -- to wring a false confession out of Izat Nafsu, a non-Arab Moslem who was a lieutenant in the Israeli Army, and then lied about it in court. The Israeli Supreme Court upheld his appeal in late May.

In both cases, the Shin Bet stepped over an invisible line, using broad powers not against the Palestinian enemy but against other Israelis -- the very people whom the agency is supposed to protect.

Some argue that the agency has been a victim of its own success, that its effectiveness has helped make Israel a relatively safe society where security considerations now occasionally take second place to other values.

"This is progress, this is how democratic states are made," said Ariel Merari, a terrorism expert at the Jaffee Center for Strategic Studies. Merari's think tank has counted 653 terrorist attacks and 56 Israeli deaths in the past three years, and he warned, "If the ability of the security services to conduct efficient investigations is curtailed severely, then certainly the result will be an increase in terrorism."

The Shin Bet's crisis has echoes of the revelations in the United States of FBI and CIA abuses in the mid-1970s. As in those cases, a combination of rival bureaucracies and an aggressive press helped bring to account an entrenched agency.

But here, senior members of the agency, angered and troubled by the alleged abuses they perceived, were the main whistle-blowers.Low Morale, High Confusion

The result is an organization at war with itself. Morale is low and confusion high about what is accepted procedure and what is not. "They feel paralyzed, frustrated and very, very embarrassed," said one source with intimate knowledge of the agency. "Right now they'll do their jobs, but no one will risk his behind."

Ironically the people who have most suffered alleged Shin Bet abuses -- Palestinian security detainees -- are the least likely to benefit from the reappraisal of its practices. Despite reversal of the Nafsu case, many human rights lawyers say they do not intend to seek judicial review of any cases, even though they estimate that 90 percent of Israel's 4,000 security prisoners were convicted largely upon confessions now open to question.

"I don't expect anything to come out of it for the simple reason that the system itself relies so heavily on confessions that it can't run any other way," says Palestinian lawyer Jonathan Kuttab. "It's never been legally permitted to torture anyone in Israel, but the way the system operates it can always be done and always be denied."

The Shin Bet is a clandestine organization that answers directly to the prime minister. Its size, budget, the location of its headquarters and even the names of its top officials are state secrets. Prime Minister Shamir rejected a request from a Washington Post reporter to interview a private attorney who has represented the agency, saying through a spokesman, "Matters that are secret ought to remain secret."

But in recent weeks, present and former Shin Bet operatives have spoken cautiously and off the record to certain Israeli journalists, some of whom are former members of the organization. Private lawyers also have passed on comments from operatives. This article is based upon those accounts, plus interviews with and affidavits of Palestinian lawyers and security prisoners who have been on the receiving end of the Shin Bet's methods of operation.

Originally the Shin Bet -- the Israeli initials of the agency, formally known as the General Security Service -- served as an Israeli-style Federal Bureau of Investigation dealing with espionage and other security crimes inside Israel. But the occupation of the West Bank and Gaza in 1967 dramatically changed its role and methods.

Shin Bet agents found themselves operating in a hostile environment where witnesses were scarce and uncooperative. The agency's emphasis shifted to preventing terrorist attacks before they took place. It was an unconventional war for which the agency quickly developed special techniques.

"A major distinction is time," said a source. "A policeman's goal is to convict you, and he has all the time in the world. But a {Shin Bet} man's main purpose is operative. They have to have information and have to have it as quickly as possible. You've got to know from a suspect the next target, when, where and how, and you can't wait." The Interrogations

For years, former detainees have made allegations of torture and ill-treatment at the hands of Shin Bet and military interrogators. In each case, Israeli authorities have pointed to the detainee's political affiliation -- mostly membership in various Palestinian movements -- to cast doubt on the charge.

But now some Shin Bet operatives are conceding publicly that illegal methods have been used regularly. Those techniques include sleep deprivation, ice cold showers, suffocation by hooding, verbal threats and, in many instances, punches, kicks to the groin and face-smacking, designed usually to frighten more than wound.

Shin Bet agents insist that these "secondary methods" have been tailored to produce accurate information. "It's the easiest thing in the world to punch a guy in the face and get him to sign a confession admitting to all the murders in Jerusalem," said the source. "But we had to get accurate information because if we are wrong, someone may pay with his life. This has been the real guarantee against serious torture."

The alleged abuses took place most commonly during the first two weeks of detention when a prisoner can be held without access to lawyers, private doctors or family members. Despite certain procedural safeguards -- mandatory medical examinations of prisoners, visits during the first 14 days of detention by a Red Cross representative and the threat of misconduct charges -- Shin Bet operatives say they worked without apparent constraints.

The ultimate safeguard is supposed to be the "mini-trial" that is held by the military court whenever a defendant alleges that his confession was illegally coerced. These hearings usually boil down to the word of the defendant against the word of his interrogators, and judges invariably accept the latter.

Local lawyers can cite only two cases in the past two years in which a confession was ruled inadmissible, and many lawyers say they rarely bother to request a review because its outcome is so uniformly predictable.

Former Shin Bet interrogator Yossi Ginossar, the man who conducted the interrogation of Nafsu, has alleged that he and other agents lied on a regular basis during the mini-trials. An associate repeated the claim and gave this explanation:

"You know the man in the box is a murderer, and you have his confession. In most cases, it is the only hard evidence you have. The guy usually exaggerates so much that you don't even have to feel bad about lying at the mini-trial. He says you hit him 50 times when maybe you hit him once. So you can deny the whole thing and be telling the truth for 49 out of 50."

For years, these agents insist, there was tacit approval of these methods because it proved effective. This year alone, according to Defense Minister Yitzhak Rabin, security services have uncovered 108 "terrorist squads," 58 of which were captured before executing planned operations.

"I know there have been some irregularities here and there," Rabin told the Knesset in early June, "but let's be cautious. {Shin Bet} is our most effective tool in the war against terrorism."

The system began to unravel three years ago with the so-called Bus 300 incident. At first, the Shin Bet and the Army worked together in covering up the killing of the two hijackers, insisting that they had died of wounds sustained when Israeli troops stormed the hijacked bus. In fact, the hijackers had been taken to a nearby field and clubbed to death by Shin Bet agents.

But when Israeli newspapers, violating censorship restrictions, published photographs showing two apparently healthy hijackers being led away from the bus, the cover-up shifted.

Shin Bet head Shalom orchestrated an effort to pin the blame on Maj. Gen. Yitzhak Mordechai, who had pistol-whipped the two men before their deaths to get information about explosives left on board the bus. Ginossar was a member of a top-secret commission that reviewed the case, and he has admitted fabricating evidence and steering the panel to recommend Mordechai's prosecution.

Mordechai was later exonerated and the cover-up collapsed after three senior Shin Bet officials went public with charges that Shalom had helped doctor evidence in the affair.

Shalom then alleged that he had received a general guideline from Prime Minister Shamir allowing the Shin Bet to execute summarily captured terrorists. Shamir denied the claim, and a Justice Ministry report later ruled it unsubstantiated.

Nonetheless, Shalom never stood trial. He and 10 other agency officials received presidential pardons after Israel's political leadership decided that a court trial could destroy Shin Bet's morale and lead to more embarrassing public disclosures. An Unsettled Score

But the pardons left an unsettled score inside Israel's justice and security bureaucracy. The chance to get even came when Lt. Nafsu asked the Israeli Supreme Court to throw out his conviction for treason and espionage because evidence had been fabricated at his trial.

The link between the two cases was Ginossar. He had defended his conduct in the bus affair by claiming that the Shin Bet's fabrication of evidence and perjury on the stand were standard operating procedure. Nafsu's lawyers used those claims to ask for a reopening of his case.

Like the Supreme Court in the United States, Israel's high court generally confines its deliberations to legal and procedural issues. But the panel deviated in the Nafsu case, reviewing specific facts and throwing out Nafsu's tainted confession and most of the charges on which he was convicted.

The court, it turned out, was helped by the Army prosecutor representing the state, who corroborated Nafsu's claims that he was subject to physical abuse and threats and that his Shin Bet interrogators had lied in court.

"It was an unprecedented decision, and it was clearly motivated by the court's frustration in the Bus 300 case," says Hebrew University law Prof. Ruth Gavison. "The court wanted to send a message to the Shin Bet -- 'Be careful, you're not beyond judicial review.' "

Shin Bet officials tried to shortcircuit the Nafsu case by arranging his early release, but Nafsu turned down the deal.

The officials panicked over the decision, fearing that their operatives would now face criminal charges for assault and perjury. They pressed instead for a judicial inquiry panel that is authorized to review the agency's practices and formulate new guidelines.

Few experts believe that any new guidelines coming out of the inquiry will be sufficient to end the clash between the competing imperatives of state security and civil liberties.

Some advocate a set of new internal security laws that would give Shin Bet broader interrogation powers. Others contend such laws would turn Israel into a Mediterranean South Africa.

Still others argue that there is no solution to the Shin Bet's dilemma so long as Israel continues to impose its rule on 1.4 million hostile Palestinians in the occupied territories.

"The real question is not what the Shin Bet does -- everyone knows about it -- but could they act any differently under conditions of occupation?" said lawyer Lea Tsemel, who handles dozens of security cases each year.

"There are many people in Israel who would like to see a pure and clean occupation. It doesn't exist. It cannot be."