A sordid tale of espionage, homosexuality, drugs and blackmail among British military forces in Cyprus was outlined by prosecutors here last week as the government opened a major spy case against seven young servicemen it alleges turned over thousands of classified documents to Soviet agents.

The seven, all assigned to a communications unit in the small town of Ayios Nikolaos on the southern Cypriot coast, are charged under the Official Secrets Act with communicating information useful to an enemy over a two-year period up to February of last year.

According to sources here, the unit gathers electronic intelligence and "photographic and intercept" material covering the Middle East and nearby parts of the Soviet Union. In addition to the 4,000 British Army soldiers and airmen stationed in Cyprus under the 1960 independence agreement, U.S. reconnaissance aircraft also are said to operate there.

Much of the information handled by the unit is said to be in code, and is transmitted to the Government Communications Headquarters based at Cheltenham, west of London, for deciphering and analysis. Officials here said that rather than providing the Soviets with information on western activites, the compromised intelligence most likely informed the Soviets of the extent of western ability to intercept Russian secrets.

[In Washington, Pentagon officials expressed concern but not alarm when asked about the possible compromise of the listening post on Cyprus. There are similar facilities in nearby Greece, they said, as well as other spots in the region providing similar intelligence collection, Washington Post reporter George C. Wilson reported.]

The case is the latest in a series of British spy scandals over the years, most involving civilian rather than military agencies and including one at the Cheltenham headquarters in 1982, which have caused concern within U.S. intelligence services that operate closely with their British counterparts.

But it comes at a time when the United States is in the process of unraveling its own military espionage ring, allegedly led by former Navy warrant officer John A. Walker Jr.

"I would have thought that with the Walker case, it would be imprudent of us to raise a fuss" about the current British problem, one knowledgeable American said here.

The jury trial at London's Old Bailey courthouse is expected to continue for several months and will be held largely in secret. But in an opening statement Monday and in a brief session held in open court Friday, the government offered explicit details of "homosexual orgies" in which the seven participated while holding their sensitive posts.

When threatened with exposure, prosecutors said, they "betrayed to the agents of a foreign power some of this country's most precious military secrets."

Queen's Counsel Michael Wright told the jury that all of the defendants "have made total confessions to spying," although each has pleaded not guilty. "When each of the defendants was asked why he had behaved in such a way," Wright said, "the explanation ultimately came down to the same thing -- blackmail.

"The basis for such blackmail in almost every case was primarily the fear of exposure for having indulged in homosexual practices; this was in many cases backed up by thinly veiled threats of violence toward themselves and their families."

In lurid detail that has been given extensive coverage in the British press, Wright said that blackmail was "by no means the only explanation. Boredom, the desire for some perverted excitement, and the opportunity to acquire money, drugs and to some extent sexual pleasure" also contributed.

The "spy ring" was discovered, the prosecution said, not because of "some lightning coup by intelligence officers." Rather it came to light when its alleged ringleader, Senior Aircraftman Geoffrey Jones, 20, "committed an elementary and stupid error."

Due to end his tour of duty in Cyprus, Jones neglected to carry out "certain clearance procedures appropriate to the type of work his unit was doing." Questioned by a security official in February 1984, Jones revealed a "close association with a foreign national" in Cyprus, a female Filipino dancer. Under additional questioning, Jones conceded homosexual involvement with a number of other British servicemen and a man he described as an Arab named "John," to whom he turned over classified information under threat of exposure.

Interviews with those named by Jones unearthed a ring of homosexual contacts he allegedly recruited within the unit, and further blackmail. Through "John," Jones and then the others were introduced to the alleged head of the operation, a KGB official on the island named "Alex."

Once investigators realized "that they were dealing with a network of spies and a major leakage of classified material," there followed "a massive escalation of the investigation [and] an inquiry of unprecedented magnitude . . . ."

While each of the seven has described the involvement of the others, Wright said, the case against each is based only on his confession of his own activities.

Clearly anticipating objections by the defense lawyers in the courtroom -- at least two per defendant -- Wright acknowledged that there were numerous contradictions and probable deceptions in the stories told by each of the accused. He said that they intentionally led investigators up numerous blind alleys by apparent prior agreement on what to do if they were caught.

But Wright said the government would prove against all a general outline of voluntary homosexual participation, entrapment and recruitment to the spy ring under threat of exposure and in exchange for money and drugs.

"Plainly," he said, "none of these men committed these offenses for any political, ideological or complex philosophical motives."

The other defendants are Senior Aircraftman Adam Lightowler, 21; RAF Senior Aircraftmen Christopher Payne, 24; Wayne Kriehn, 20; Gwynfor Owen, 21; Army Signalman Martin Tuffy, 22, and Lance Cpl. Anthony Glass, 31. An eighth defendant, Army Signalman David Hardman, was acquitted of charges Monday.