WASHINGTON — The House chaplain scored a legal victory on Good Friday, when a federal appeals court ruled he could not be ordered to allow a self-described atheist to offer a secular prayer to the House of Representatives.

The U.S. Court of Appeals for the D.C. Circuit sided with the Rev. Patrick J. Conroy, in his official capacity as the House chaplain, and the House itself in litigation brought by Dan Barker, co-president of the Freedom from Religion Foundation and a former minister. Barker alleged Conroy improperly rejected a request to have him serve as guest chaplain.

In the decision released Friday, a three-judge appeals court panel affirmed a lower court’s decision to dismiss Barker’s claim that his rights were violated under the Establishment Clause, though the judges offered a different take on the case from the district court.

Writing for the court, Judge David S. Tatel explained that the legal question was not whether Barker was blocked from offering a prayer because he was an atheist, but rather about the content of that prayer.

“To resolve this case, however, we need not decide whether there is a constitutional difference between excluding a would-be prayer-giver from the guest chaplain program because he is an atheist and excluding him because he has expressed a desire to deliver a nonreligious prayer. Even though we accept as true Barker’s allegation that Conroy rejected him ‘because he is an atheist,’” Tatel wrote. “The House’s requirement that prayers must be religious nonetheless precludes Barker from doing the very thing he asks us to order Conroy to allow him to do: deliver a secular prayer.”

The court noted that Conroy revised his explanation for why he excluded Barker from offering the prayer. Initially, it was about the fact that Barker is not a recognized or ordained religious figure.

“But during the course of this litigation, Conroy has taken a different position: that Barker could not serve as guest chaplain because he sought to give a secular prayer. More important, the House of Representatives itself, through House counsel, has now ratified that position,” the court explained. “Both in briefing and at oral argument, House counsel represented to this court that the House interprets its rules to require ‘a religious invocation.’”

While the Freedom from Religion Foundation may appeal, the ruling from the D.C. Circuit appears to suggest it is up to the House to consider the question of the rules governing its own daily prayers, which have been a regular feature of the proceedings since 1789.

It was under the leadership of Wisconsin Republican and then-Speaker Paul D. Ryan that the House counsel defended Conroy’s official position in the litigation.

Rep. Mark Pocan, a Democrat from Wisconsin, had invited Barker to serve as guest chaplain back in 2015, which started the yearslong legal debate. Barker filed suit in 2016.

Legislative prayer itself was upheld by the Supreme Court in 2014, in a case that involved prayers offered at public meetings in the small upstate New York town of Greece.