The Justice Department dropped its perjury case against International Telephone and Telegraph Corp. executuve Edward J. Gerrity Jr. yesterday, citing fears that national secrets might be disclosed at trial.

The decision was no surprise because the government dropped a companion case against ITT official Robert Berrellez a month ago for the same reason.

Yesterday's action ends a five-year effort to prosecute ITT and CIA officials who allegedly lied to a Senate subcommittee in 1973. The panel was investigating ITT-CIA collusion in trying to prevent the election of Marxist Salvador Allende in Chile in 1970.

Former central intelligence director Richard M. Helms was allowed to plead "no contest" in late 1977 to charges he misled the Senate during his testimony on the case.

Attorneys for the nation's former chief intellignce officer had said Helms might have to disclose during his defense the very secrets he's allegedly lied about to the Senate in order to protect. Justice officials said fear of such disclosure was a key factor in letting Helms plead to a lesser charge.

The final action in the Gerrity case yesterday came in a three-paragraph "motion to dismiss" by Justice prosecutor John T. Kotelly. "The reason for dismissal is to protect classified national security information from public disclosure. The government believes that to proceed any further would risk the disclosure of information that the government must take every reasonable, appropriate step to avoid." Kotelly wrote U.S. District Court Judge Aubrey E. Robinson Jr.

Walter Bonner, Gerrity's attorney, said yesterday that he was "very pleased" to learn of the government's decision. Gerrity, reached in Florida where he is vacationing, said, "We didn't think they had a case."

Philip B. Heymann, head of the criminal division at Justice, said, "I hate every time I have to dismiss a case like this."

Attorney General Griffin B. Bell said at the time charges were returned against Gerrity and Berrellez almost a years ago: "You cannot decide never to prosecute these cases that might involve national security. To do so gives people a license. That just can't be the law."

Sen. Frank Church (D-Idaho), chairman of the Senate subcommittee that heard the ITT-Chile testimony six years ago, severely criticized Justice a month ago for dropping the Berrellez case. Church, now chairman of the full Foreign Relations Committee, was traveling yesterday, but an aide said his comments applied equally to the Gerrity decision.

The senator had said future witnesses might feel free to mislead Congress because of the government's handling of the ITT-Chile cases. He also said the decision appeared mainly to protect the CIA and a major corporation from embarrassment.

In a telephone interview yesterday, Heymann said. "I worry about free rides. Sometimes the cases are very hard and a statute might help us."

He said "there's been no effort in any case I've seen to cover up governmental wrongdoing."

In an effort to save the Berrellez and Gerrity cases, Heymann tried unsuccessfully to get Robinson to agree to novel court procedures whereby the government could argue secretly against proposed defense evidence prior to its being introduced. A U.S. Court of Appeals panel also rejected the Justice argument.

A Justice task force under Heymann's direction is now drafting legislation he hopes will be at least a partial solution to the problems raised in the ITT-Chile cases, he said.

This might include procedures to give the prosecution a pretrial ruling on the relevancy of defense evidence involving national secrets and a less technical basis for appealing lower court rulings unfavorable to the government in such cases.

The problem Justice faces in national security cases has been referred red to as "graymail" -- just a shade lighter than blackmail -- because of defense attorneys' efforts to find some relevant secret the government can't disclose.

The "national security" factor has been raised by defense attorneys in a recent case involving the proposed prosecution of a former top Lockeheed Aircraft Corp. official and in the current, delayed conspiracy case against three former top FBI officials accused of authorizing illegal breakins in search of the radical Weather Underground.

Justice officials defend their spotty success rate. "At least we're trying to bring these cases," one ITT prosecutor said yesterday. "Ten years ago, a mention of 'national security' could stop an investigation."

Critics have charged that the government changes its definition of "national security," narrowing it to bring charges in even minor espionage cases and widening it to prevent charges in cases involving intelligence officers or large corporations with operational ties to the CIA.