SAN FRANCISCO, AUG. 9 -- Independent counsel Lawrence E. Walsh said today that neither the "popularity" nor good intentions of those involved in the Iran-contra affair will be a factor in deciding whether to bring criminal charges against them.

In his first public remarks since the end of congressional hearings, Walsh clearly was referring to Lt. Col. Oliver L. North, who ran the Iran-contra operations while he was a National Security Council aide. According to polls, North's popularity soared after his testimony last month before the congressional panels investigating the sales of arms to Iran and diversion of profits to aid the Nicaraguan rebels.

Walsh said congressional grants of limited immunity to "central figures" in the affair -- such as North and former national security adviser John M. Poindexter -- have posed "the most serious external threat" to his investigation. But, he said, "We think we have met it, and we intend to go ahead."

In a news conference after his speech to the American Bar Association meeting here, Walsh declined to comment on suggestions that President Reagan grant pardons to North or others involved in the Iran-contra affair.

"That's not my area of responsibility," said Walsh, a former federal judge and ABA president.

Although Walsh and almost all the members of his staff have been carefully shielded from being "tainted" by seeing or reading about the testimony of immunized witnesses, Walsh said he was not able to escape the impression that North was a popular witness.

Walsh said his wife, Mary, related the story of a woman who asked her hairdresser for a "Betsy North" haircut, and that his daughter called him after North's testimony "and said, 'Gee, until now, I never realized how difficult your job was.' "

He said one person told him of getting an "Oliver North for President" bumper sticker and that one woman seeing him on the street rolled down her car window and said, "I think of you every day. You're having such a run of bad luck."

However, he said, "Obviously, the rule of law makes clear that no person is to be treated differently than any other because of high office, because of popular policies, because of well-intended policies . . . . Popularity is in no sense a proper factor for consideration, any more than unpopularity."

Walsh said North's popularity "had no effect" on his office, although "any event that happens causes reconsideration."

Although Walsh argued strenuously against grants of immunity to witnesses such as North and Poindexter, he said those decisions were a legitimate "political judgment" by Congress, which had "to move quickly" in getting out the story of the Iran-contra affair.

He said he is confident that if immunized witnesses are prosecuted, "such persons will not be able to escape criminal responsibility on the basis of the congressional grants of immunity."

To prosecute successfully individuals who have been granted "use immunity" by Congress, Walsh's office must prove that its case was not based on the immunized testimony or any leads derived from it.

Walsh also rejected arguments that it would be unfair to prosecute witnesses who had been compelled to testify under grants of immunity.

"Once the law is complied with" and the immunized testimony is not used against the witness, immunity "should not be used as an element of discrimination among potential defendants," Walsh said.

Walsh said the American system is premised on honesty and adherence to the rule of law, and he emphasized the need for federal officials to deal truthfully with those in other branches of government and with the American public.

"When there is an attempt to cheat, to lie or to obstruct, the system falls," Walsh said. "Secrecy is one thing; lying is another . . . . The whole system breaks down when secrecy is given as an excuse for lying or for deceit."

North and Poindexter both testified they lied to Congress and other U.S. officials to guard the Iran-contra initiative -- including the effort to free hostages held in Beirut.

In his address to an ABA prayer breakfast, Walsh traced the importance of truth and the rule of law through the Judeo-Christian tradition -- from the Bible through English common law to the U.S. Constitution.

"Under a system of law, truth becomes critical," he said. "Honest dealing between the branches of our government . . . is necessary to make the separation of powers work." Moreover, he said, "The whole concept of democracy presupposes that the voters are going to be able to make intelligent decisions based on known facts."

Walsh said his office has spent nearly $1.8 million on the investigation since it was set up in December.