Seven British servicemen charged with passing secrets to Soviet agents while stationed in Cyprus have been acquitted after one of the longest and most expensive spy trials in this country's history.

A 12-man jury today found the last two defendants not guilty after acquitting the other five last week. The final verdict released a storm of criticism from opposition leaders and even some members of Parliament on the government side, who questioned the way in which the investigation leading to the trial was handled.

Nearly all of the four-month trial was held in secret. But instructions given the jury by the judge and comments today by the principal defense attorney indicated that the acquittals came after the defendants retracted allegedly coerced confessions.

Opposition Labor Party defense spokesman Denzil Davies called on Defense Secretary Michael Heseltine to explain "the methods used" by Royal Air Force police "to try and extract confessions from these young and inexperienced men."

The seven defendants are low-level servicemen in the RAF and British Army who were assigned to a communications unit in the small town of Ayios Nikolaos on the southern Cypriot coast. The unit gathers electronic intelligence, reportedly including some collected by U.S. aircraft stationed there, from the Middle East and nearby parts of the Soviet Union.

The seven were charged under the Official Secrets Act with communicating "information useful to an enemy" over a two-year period until February 1984.

When the trial opened last June, the prosecution alleged that the seven had become involved in a homosexual and drugs ring set up by a Cypriot, an Arab and an officer of the Soviet KGB. Threatened with exposure, the charge continued, they agreed to turn over classified documents and "betrayed to the agents of a foreign power some of this country's most precious military secrets."

The prosecution said the alleged spy ring was discovered in early 1984 when its "ringleader," RAF telegraphist Geoffrey Jones, 20, revealed "a close association with a foreign national" during security questioning prior to a routine transfer. It was Jones, prosecutors said, who first was blackmailed into turning over secrets and recruiting the others by holding homosexual "orgies at which drugs were used."

The prosecution charged that Jones alone had passed 200 top-secret documents and 800 documents classified as secret and confidential.

Following their arrests, the seven servicemen never were allowed to see each other and were interrogated repeatedly over a period of 16 months before the case was brought to trial.

Each of the defendants pleaded not guilty to the charges and during the trial denied having participated in the alleged "orgies." They asked to have the confessions excluded on the ground that they had been improperly obtained.

Although the judge denied the request in the cases of at least three of the defendants, including Jones, testimony about their interrogations clearly influenced the jury.

In their statements, summarized by the judge in open court, the servicemen alleged verbal abuse and threats of indefinite imprisonment.

According to press reports here, the investigation and trial cost the state more than $6 million.