A U.S. Court of Appeals panel here ruled yesterday that the State Department cannot deny temporary visas to aliens solely because of their political beliefs or associations.

The panel, split 2 to 1, also said that in most cases the government would have to certify that an alien's planned activities in this country would be a national security threat before it could deny such a visa.

The ruling involved three suits challenging the department's denial of visas to Nicaraguan Interior Minister Tomas Borge, an Italian peace activist and two members of the Federation of Cuban Women.

Civil liberties groups and some congressman praised the decision, saying it would end what they described as a Reagan administration policy of refusing entry to anyone whose political views it opposed.

"I think it is an extremely important decision," said Steven Shapiro of the New York Civil Liberties Union, which brought the suits. "It means they can't keep out people because of their beliefs or if they are worried about the symbolism of the person being here. The court said it won't cut off debate in this country."

Rep. Don Edwards (D-Calif.), who had met Borge in Nicaragua and was to meet with him here, said, "I can't imagine why we should be frightened by one of the commandantes coming here. We have been overwhelmed by the contras coming, being entertained at the White House and getting on TV."

James G. Hergen, the State Department's assistant legal adviser for consular affairs, said he received the opinion late yesterday and had not been able to study it. "These are serious policy issues and we will be reviewing the case carefully with a view toward asking for reconsideration or an appeal" to the Supreme Court, Hergen said.

Yesterday's ruling reversed U.S. District Court Judge Harold H. Greene's 1984 decision upholding denial of the visas and strongly criticized his reliance on State Department affidavits that were not provided to attorneys for the other side.

The department rejected visa applications in 1983 for Borge; Nino Pasti, a former North Atlantic Treaty Organization general who opposes the deployment of cruise and Pershing missiles in Europe, and Olga Finlay and Leonor Rodriquez Lezcano of the Federation of Cuban Women. The four were scheduled to make speaking tours in this country.

The visa for Pasti, also a former member of the Italian Senate, was denied solely because he is a member of the Communist Party. Of Borge, Finley and Lezcano, the department said their speeches in this country would be "prejudicial to the public interest."

The administration, using the same justifications, has also denied visas to Hortensia Allende, widow of slain Chilean president Salvadore Allende; Ricardo Alarcon and Jose Viera, Cuban ministers of foreign relations; Robert D'Aubuisson, president of El Salvador's Constituent Assembly, and Canadian author Farley Mowat.

Rep. Barney Frank (D-Mass.), sponsor of a bill that would remove many ambiguities in the laws covering visas, said the ruling "strengthens the case for legislation" and predicted hearings by the end of the month.

The opinion was written by Appeals Court Judge Ruth Bader Ginsburg, with Judge Harry T. Edwards concurring and Judge Robert H. Bork dissenting. Greene was criticized for upholding the visa denials on the basis of affidavits from State Department officials that contained classified information and were never provided to lawyers for the groups sponsoring the speakers.

Describing access to evidence as a "halllmark of our adversary system," the appeals court sent the cases back to Greene, saying it expected the judge to keep that in mind as he reexamines the case.