The Washington region’s transit system can bar religious messages on its buses and trains and in its stations, a federal appeals court ruled Tuesday as it upheld Metro’s policy prohibiting issue-oriented advertisements.

The ruling in Metro’s favor from the U.S. Court of Appeals for the District of Columbia Circuit came in response to a lawsuit from the Archdiocese of Washington, which said the transit system’s policy had gone too far in rejecting its religious-themed ad campaign.

The archdiocese’s “claim of discriminatory treatment is based on hypothesis,” wrote Judge Judith W. Rogers. “Were the Archdiocese to prevail, WMATA (and other transit systems) would have to accept all types of advertisements to maintain viewpoint neutrality, including ads criticizing and disparaging religion and religious tenets or practices.”

Rogers was joined by Judge Robert L. Wilkins, who wrote in a separate concurrence that the policy was reasonable and within the bounds of the First Amendment because it “does not take sides” when it comes to religion.

The third judge on the panel, Brett M. Kavanaugh, referred to Metro’s ban as “pure discrimination” during oral argument in March. But Kavanaugh, who is now President Trump’s Supreme Court pick, did not participate in the decision Tuesday because of his pending nomination.

For decades, the transit system allowed a range of advertisements, ­including political satire and criticism of the Catholic Church. But in 2015, Metro banned issue-oriented messages as well as any related to religion or politics because of security concerns over anti-Muslim-themed ads.

The policy limits ads to commercial products and services, which bring in more than $20 million for the agency that relies on funding from the District, Maryland, Virginia and the federal government.

Under Metro’s policy, “advertisements that promote or oppose any religion, religious practice or belief are prohibited.”

The archdiocese’s lawsuit is one of a long list of recent challenges to the strict guidelines. Metro also has been sued over the policy by the American Civil Liberties Union, People for the Ethical Treatment of Animals, an abortion provider and the controversial author Milo Yiannopoulos, among others.

After the Tuesday ruling, the archdiocese is reviewing the decision to determine its next steps. Ed McFadden, secretary of communications, said in a statement that the ruling is a reminder that “freedom of religions and expression in the public square should never be taken for granted, and we will continue to defend those rights at every opportunity.”

The archdiocese went to court last fall after its Christmas-themed ads were rejected and asked a lower-court judge to issue an injunction requiring the agency to display the banners. The planned “Find the Perfect Gift” ads featured a biblical Christmas scene and a link to a website that encouraged people to attend Mass or donate to a Catholic charitable group.

In December, the federal judge rejected the request for a preliminary injunction.

On appeal, lawyers for the archdiocese, including former solicitor general Paul D. Clement, told the U.S. Court of Appeals for the D.C. Circuit that the policy violates the First Amendment and the Religious Freedom Restoration Act. The archdiocese also had the support of Attorney General Jeff Sessions. The Justice Department had argued that the policy was applied inconsistently.

Metro’s outside counsel, Donald B. Verrilli Jr., another former solicitor general, told the court that accepting the archdiocese’s ads would force the agency to accept other religious-themed ads that could cause “tension and divisiveness” and interfere with the agency’s ability to run the system.

At oral argument, the archdiocese said Metro’s policy unfairly and unconstitutionally singled out the church by allowing secular advertisers to promote Christmas shopping and charitable giving.

In its 35-page ruling, the court said the archdiocese’s ad campaign is primarily about religion — not charitable giving — and part of its acknowledged effort to encourage attendance at Catholic Mass.

The imagery in the ad is “evocative not of the desirability of charitable giving, but rather the saving grace of Christ,” Rogers wrote. “Had the Archdiocese wished to submit an ad encouraging charitable giving, nothing in the record suggests it could not do so.”

The court said the archdiocese had not shown that Metro’s policy impermissibly favors one point of view or religion over another because it broadly eliminates all religious content.

Wilkins noted in his separate opinion that the Supreme Court has repeatedly said that the government — in this case, the publicly funded transit system — may restrict certain types of private speech as long as the restrictions are “not a cover for suppressing viewpoints with which the government disagrees.”

Metro’s rule is acceptable, he wrote, because it “does not take sides; it restricts all speech on the topic equally, without discriminating within the defined category.”