WASHINGTON — In a major ruling on press freedoms, a divided federal appeals court on Friday ruled that James Risen, an author and a reporter for The New York Times, must testify in the criminal trial of a former Central Intelligence Agency official charged with providing him with classified information.

In a 118-page set of opinions, two members of a three-judge panel for the United States Court of Appeals for the Fourth Circuit, in Richmond, Va., ruled that the First Amendment does not protect reporters who receive unauthorized leaks from being forced to testify against the people suspected of leaking to them. A district court judge who had ruled in Mr. Risen’s case had said that it did.

“Clearly, Risen’s direct, firsthand account of the criminal conduct indicted by the grand jury cannot be obtained by alternative means, as Risen is without dispute the only witness who can offer this critical testimony,” wrote Chief Judge William Byrd Traxler Jr., who was joined by Judge Albert Diaz in Friday’s ruling.

Mr. Risen has vowed to go to prison rather than testify about his sources and to carry any appeal as far as the Supreme Court. But some legal specialists said an appeal to the full appeals court was a likely first step. Mr. Risen referred a request to comment to his lawyer, Joel Kurtzberg, who wrote in an e-mail: “We are disappointed by and disagree with the court’s decision. We are currently evaluating our next steps.”