A federal appeals court ruled Thursday that the city has a constitutional right to bar religious groups from using public schools for services.

In a 2-1 decision, the Second Circuit Court of Appeals overturned a 2012 ruling by Manhattan federal Judge Loretta Preska, who had found the city’s former Board of Education — now the Department of Education — was violating the First Amendment by blocking an evangelical church, The Bronx Household of Faith, from holding Sunday services at PS 15 in University Heights.

“We conclude that the Board [of Education’s] prohibition was consistent with its constitutional duties,” the panel wrote in its 37-page opinion shooting down Preska’s decision to allow religious activities in public schools.

The ruling is the latest twist in a 19-year-old lawsuit in which the church sued the city saying it was unconstitutional to deny their Sunday services at the school when the same space was being offered to other groups. It was the sixth time the suit has been before the panel on various issues.

The church’s co-pastor Robert Hall called the decision a “heckler’s veto,” suggesting that the ruling stifled the 60-member congregation’s free-speech rights.

But services will continue, he added, explaining that the church had just put the finishing touches on its own building across from PS 15 and would begin services there once it passes inspection.