LONDON (AP) — Britain’s opposition Labour Party has the right to prevent tens of thousands of new members from voting in the party’s leadership contest, Britain’s Court of Appeal ruled Friday.

The left-of-center party is in turmoil amid an attempt to unseat leader Jeremy Corbyn. The party’s more centrist members consider the 67-year-old left-winger ineffective and unelectable.

He is facing a challenge from legislator Owen Smith in a leadership election that will be decided by party members and supporters, with the winner declared next month.

The party executive ruled last month that only members of at least six months’ standing could vote in the contest. Five Labour members challenged the decision, and on Monday a judge agreed the party was wrong to disenfranchise people who had joined believing they would be able to vote.

But the party lodged an appeal, and on Friday three judges said the lower-court judge had “erred in law.”

Announcing the ruling, judge Jack Beatson said Labour’s National Executive Committee “has the power to set the criteria for members to be eligible to vote in the leadership election in the way that they did.”

The ruling deepens the split in the party and disenfranchises almost 130,000 new Labour members — many of them thought to support Corbyn, who was elected leader a year ago.

He remains popular among party members. But most Labour lawmakers accuse Corbyn of failing to present a compelling alternative to the Conservative government and of showing half-hearted support for European Union membership during Britain’s recent referendum campaign.

The divide between pro- and anti-Corbyn factions has grown bitter, with allegations of bullying on social media and a heated atmosphere at local party meetings.