A federal appeals court in Manhattan on Friday reversed a lower-court ruling that had allowed the government to bar a prominent Muslim scholar from entering the United States on the ground that he had contributed to a charity that had connections to terrorism.

The scholar, Tariq Ramadan, 46, a Swiss academic, was to become a tenured professor at the University of Notre Dame, but the Bush administration revoked his visa in 2004 and again denied him a visa in 2006. The government cited evidence that from 1998 to 2002, he donated about $1,300 to a Swiss-based charity that the Treasury Department later categorized as a terrorist organization because it provided money to Hamas, the militant Palestinian group.

Professor Ramadan said in a later court affidavit that he was not aware of any connections between the charity, the Association de Secours Palestinien, and Hamas or terrorism, and that he believed that the organization was involved in legitimate humanitarian projects. “I have condemned terrorism at every opportunity,” he wrote.

In its ruling on Friday, a three-judge panel of the United States Court of Appeals for the Second Circuit held unanimously that the government was required to “confront Ramadan with the allegation against him and afford him the subsequent opportunity to demonstrate by clear and convincing evidence that he did not know, and reasonably should not have known, that the recipient of his contributions was a terrorist organization.”

The record was unclear as to whether a consular officer who had denied the visa had done so, the panel said in its ruling, written by Judge Jon O. Newman and joined by Judges Wilfred Feinberg and Reena Raggi.

The panel sent the case back to the lower court for a determination on whether Professor Ramadan had been confronted with the allegation, and then given a chance to deny it.

If that did not happen, the panel said, a new visa hearing should be held.

“I am gratified that the court has found that my exclusion from the United States is without basis,” Professor Ramadan said in a statement on Friday.

Professor Ramadan, who had frequently visited the United States in the past, lecturing and attending conferences, said he was eager to “engage once again with Americans in the kinds of face-to-face exchanges” that were “crucial to bridging cultural divides.”

“I hope to be able to come back to the States and resume my work with scholars,” he said later in a telephone interview. “This is what I want.”

Yusill Scribner, a spokeswoman for the United States attorney’s office in Manhattan, which argued the case for the government, declined to comment.

The government, in barring Professor Ramadan, had first offered no explanation, and then cited a provision of the Patriot Act that allows for the exclusion of foreigners who use “a position of prominence within any country to endorse or espouse terrorist activity.”

In 2006, the American Civil Liberties Union and New York Civil Liberties Union sued on behalf of three groups: the American Academy of Religion, the American Association of University Professors and the PEN American Center. The suit argued that Professor Ramadan’s exclusion violated the First Amendment rights of groups that wanted to meet with him and hear his views.

The government then cited, as the reason for denying him entry, his donations to the charity, which he had revealed in interviews with officials in the United States Embassy in Bern, Switzerland.

Jameel Jaffer, the A.C.L.U. lawyer who argued the appeal, said he was pleased with the decision and its finding “that in this case the government simply has not offered a constitutionally adequate justification for its actions.”