As the cases of four Navy men accused of espionage move closer to trial, government prosecutors and defense lawyers are preparing to do battle over what will inevitably become a central legal issue in the case: balancing the need to protect defense secrets against the rights to a fair trial of those accused of selling them.

The cases are expected to be tried in three separate jurisdictions, with John Anthony Walker Jr. and his son Michael Lance Walker standing trial in Baltimore, Arthur James Walker in Norfolk and Jerry Alfred Whitworth in San Francisco. Federal prosecutors from those three cities met with Justice Department officials and others here yesterday to start ironing out the normal wrinkles inherent in such a transcontinental prosecution, as well as those complications peculiar to a high-profile espionage case.

Among the legal issues they face is the danger that defense lawyers will engage in so-called "graymail," the tactic of trying to force the government to drop cases or offer plea bargains by insisting on the necessity of introducing sensitive information into evidence.

For their part, defense lawyers in espionage cases generally say they must be able to review relevant classified documents -- and, if necessary, use them in court -- to present an adequate defense.

"Defense attorneys, for good reasons or as a form of blackmail, will say that making their defense requires revealing secrets," said Harvard Law School Prof. Philip B. Heymann, who headed the Justice Department's criminal division under President Carter. "It's almost part of the game of espionage trials."

A 1980 law designed to address the problem of "graymail" -- a compromise endorsed by both the CIA and the American Civil Liberties Union -- established procedures designed to safeguard both the rights of defendants and national security.

Called the Classified Information Procedures Act, the law requires 30 days' advance notice of what classified information is to be used at trial, and provides for closed pretrial hearings to determine whether the information is relevant and -- even if it is -- whether other, less sensitive documents or summaries can be substituted.

Previously, defendants who contended they needed to introduce classified information at trial sometimes succeeded in forcing the government to drop the case against them rather than risk revealing the information.

With the law, said Assistant Attorney General Stephen S. Trott, the government has "the capacity to surface and prosecute spies without compromising security" or letting defense lawyers "spew secrets all over the place."

"The whole point is none of this using classified material in court comes as a surprise to the government," said Allan Adler, legislative counsel of the Washington ACLU. "The government felt they were being squeezed by defense lawyers raising classified material even when it wasn't necessary."

Even with the law's passage, however, the underlying tension between secrecy and fair trial persists, and is almost certain to emerge in the Walker cases.

As part of its burden, the government must explain in court how national security may have been damaged by the alleged spy network, and defense lawyers must have the chance to rebut such assertions -- a requirement that necessarily entails some revelation of defense secrets.

Chief of Naval Operations Adm. James Watkins said last week that the four accused spies may have caused "very serious" damage to national security by revealing information about secret Naval communications. Other top Navy officials have said the alleged espionage ring may have given the Soviets secrets about sensitive submarine operations.

Precisely how prosecutors go about proving that is likely to be determined in part by another set of tensions within the government.

If the Walker cases follow the pattern of other espionage trials, prosecutors bent on obtaining convictions and stiff sentences will want to charge that the men passed extremely sensitive information. Intelligence officials whose priority is protecting defense secrets, on the other hand, will want to keep revelations to a minimum, and may be more inclined to support plea bargains to avoid the necessity for public trial.

An additional incentive to permit a plea bargain is intelligence officials' desire to determine precisely what information the defendants may have passed to the Soviets -- an assessment that can be made most accurately with the cooperation of one or more of the accused spies.

"There is enormous tension between the prosecutors and the intelligence community," said lawyer Mark Lynch, who is representing Navy intelligence analyst Samuel Loring Morison, accused of espionage in the sale of classified satellite photographs of Soviet ships to a British defense magazine.

Another force affecting the Walker case is Navy officials, who have said they want to make certain that those accused of spying are severely punished if they are convicted. For that reason Navy Secretary John F. Lehman Jr. had considered having two of the accused recalled to active duty to stand court-martial; Assistant Attorney General Trott said the cases would proceed in federal court but vowed that those convicted of espionage would not "get off light."

The ACLU's Adler said the sheer volume of information the men charged in the Walker case allegedly sold could make the cases easier to try than other espionage cases. Prosecutors, he noted, will have the luxury of picking among numerous documents to introduce in court only those whose disclosure would be deemed less damaging.

"The government can decide what kind of sacrifice it's going to have to make in this," he said.

Meanwhile, defense lawyers have set up a chorus of complaints about prejudicial publicity they say has threatened their clients' chances for a fair trial.

They cite, among other things, what one lawyer called "rather hysterical statements" about the damage to national security and calls by Defense Secretary Caspar W. Weinberger and other top administration officials to reimpose the death pealty for espionage.

Unlike other cases, defense lawyers say, the problem of pretrial publicity cannot be solved through the usual means of moving the trial to a different location, since publicity about the so-called "Walker spy case" has been national in scope.

Other than in their lawyers' complaints about publicity, the defendants hardly appear to present a united front. Arthur Walker's lawyer said Tuesday that his client wants to distance himself legally from his younger brother, John Walker, the alleged ringleader of the network. What solidarity remains among the defendants could disintegrate if one or more agree to cooperate with prosecutors.

One scenario is that one or more will testify against John Walker, whom law enforcement officials are painting as the major player in the alleged espionage ring. Arthur Walker has confessed to giving his brother classified documents and Michael Walker has admitted passing documents as well, according to FBI affidavits and court testimony.

John Walker's lawyer, Fred Warren Bennett, acknowleged yesterday that the possiblity of the other defendants ganging up on testifying against his client "is a well-recognized tool of the trade." However, he said, "We are going to prepare to try this case against the government, not against the codefendants."