A federal court of appeals in Richmond yesterday upheld a U.S. district court judge's dismissal of Iran-contra criminal charges against a former CIA agent because the government refused to allow use of certain classified information considered crucial to the defense.

The case involved Joseph Fernandez, a 22-year veteran of the agency who as CIA station chief in Costa Rica from 1984 to 1986 assisted then-White House aide Oliver L. North in the secret resupply network for the contras. Fernandez was charged by Independent Counsel Lawrence E. Walsh with making false statements about his work with North to two sets of government investigators in early 1987 as the Iran-contra scandal was unfolding.

The unanimous three-judge decision yesterday is another legal setback for Walsh, who just two days ago filed for a rehearing on another appellate court decision that set aside the three-count conviction of North.

Fernandez's lawyer, Thomas Wilson, said his client was "extremely gratified at the result." Fernandez, who left the agency in 1988, is currently a business partner of North.

Walsh issued a statement saying it was his "understanding" that Attorney General Dick Thornburgh "will now give final consideration as to the release of the pertinent information in light of the court of appeals decision."

A spokesman for Thornburgh said the attorney general was out of town and would not issue a statement until he reviewed the matter. If Thornburgh does not permit the material to be released, Walsh can drop the case, seek a rehearing before the court of appeals in Richmond, as he did with the North case, or he can appeal yesterday's decision to the Supreme Court.

Meanwhile, in federal court in Baltimore, another Walsh Iran-contra prosecution is facing difficult going, in part because of testimony Wednesday by the government's own witness, retired Maj. Gen. Richard V. Secord, North's colleague in the secret resupply operation.

Secord testified he believed records that form part of the foundation for this Walsh prosecution had been "falsified."

Secord's statement from the witness stand surprised government attorneys who are prosecuting Secord's friend and aide in the resupply operation, Thomas G. Clines, for failing to report income from the arms sales on his 1985 and 1986 income tax returns. Part of the government's case against Clines, a former CIA operative, is based on the record books Secord charged were "cooked."

To help repair the potential damage of Secord's statement with the jury, prosecutors yesterday changed the original order of their witnesses and put on the stand the head of the company that maintained the accounting books to show that they were handled correctly.

The Fernandez case presented a different set of problems for Walsh.

The veteran CIA operative was accused of making false statements to Tower Board investigators about his role with North in building a secret airstrip in Costa Rica that would help the resupply operations. He also was accused of making misstatements to the CIA inspector general.

To defend himself, Fernandez sought to use CIA documents and facts about agency activities in Costa Rica that he said would show the airstrip was part of a CIA plan to help that country defend itself from the Sandinista regime.

In addition, he wanted to show he had no reason to lie about the resupply operation because the papers he sought would demonstrate that "CIA headquarters {had been provided} with detailed information about the resupply program, and that CIA officials "throughout. . . were intimately involved in the resupply of the contras," according to yesterday's decision.

The CIA, however, refused to release the detailed information that Fernandez and the district court judge believed necessary for his defense, and the appellate judges agreed with that decision.

In a 40-page decision, the judges concluded that lack of what it termed "crucial evidence" would have deprived Fernandez of any real chance to defend himself.