All’s fair when it comes to slaughtering fowl on the streets of Brooklyn, a judge ruled Monday, clearing the way for thousands of chickens to be killed next week in a 2,000-year-old ritual.

Manhattan Supreme Court Justice Debra James ruled that the Orthodox practice of Kaporos, during which chickens are slaughtered before the high holy day of Yom Kippur to atone for sins, can proceed, knocking down a challenge by a Brooklyn animal-rights group.

The ruling came on Rosh Hashanah, the Jewish New Year, which starts the 10-day holy period leading up to Yom Kippur.

“No one has the right to change our religion, and this ruling proves we can’t be touched,” cheered Yossi Ibrahim, 27, in the Hasidic enclave of Crown Heights.

A group of residents calling themselves The Alliance to End Chickens as Kaporos had sued the city, the NYPD and local Jewish leaders in state Supreme Court, arguing that the ritual was inhumane and unsanitary.

According to court documents, “The Kaporos ritual . . . involves the practitioners’ grasping of live chickens by their wings and swinging them above their heads three times and reciting prayers.

“The purpose of this act is to transfer the practitioner’s sins to the birds. After swinging the bird, the adherents slit the chickens’ throats with a sharp knife. The meat is then donated to the poor,” papers state.

The alliance argued that the ritual had grown into a “carnival-like and chaotic public nuisance,” as more and more participants inhumanely kill the birds and then leave their bacteria-teeming carcasses in the street.

Critics also scoffed at the notion that the dead birds were distributed to the poor afterward.

But the defense argued that the case was about religious freedom — and allowing participants to carry on a ritual that “has been practiced for at least 2,000 years.’’

Justice Debra James sidestepped the religious argument, saying there just wasn’t enough proof that the ritual was a public nuisance.

Meanwhile, Nora Constance Marino, the activists’ lawyer, said she was “devastated.”

“I’m beside myself right now,’’ she said. “I’m devastated because this is an egregious event with respect to public-health issues, quality-of-life issues and animal-cruelty issues.

“To be forced to endure opening up your front door annually to a mass animal slaughter is just dumbfounding.”