ANKARA (Reuters) - Turkey’s main pro-Kurdish party elected new leaders on Sunday, at a congress that party officials said authorities had tried to stop by arresting hundreds of would-be attendees.

The Peoples’ Democratic Party (HDP) met to replace Selahattin Demirtas, its leader since June 2014 and the person who took it into parliament for the first time, as he is in jail facing charges of supporting terrorism and said he would not seek re-election.

The party unanimously elected Istanbul lawmaker Pervin Buldan and Deputy Co-Chairman Sezai Temelli, the only candidates, as the new leaders of the second-largest opposition party in Turkey’s parliament.

The party said delegates’ cars were stopped and they were subjected to frequent ID checks by police who detained around 500 people in the days leading up to the congress, attended by 32,000 members and supporters.

Former co-chair Serpil Kemalbay called the arrests “arbitrary” and said the government had tried to stop the congress “being held in a healthy way”.

The detentions were part of Turkey’s crackdown on those who oppose its operation against the YPG militia in northwestern Syria. Turkey considers the YPG an extension of the outlawed Kurdistan Workers Party (PKK) and has detained some 600 people for protests or social media posts against the campaign.

“We will not be a part or accomplice of this dark and lawless period in Turkey’s history,” Buldan told the congress prior to her election.

“No matter how much they try to isolate us, no matter how much they try to discourage us by force and oppressive policies, we will rely on the spectacular strength of our rights and legitimacy that shines like the sun.”

Buldan’s husband was murdered in 1994, after the government said it had a list of businesspeople who were funding the PKK. The killer was never identified.

Former leader Demirtas faces up to 142 years in prison. He and other HDP members are accused of links to the PKK, which has waged a three-decade insurgency and is classed by Turkey, the United States and the European Union as a terrorist group. They deny the charges.

Under Turkish law, someone convicted of terrorism cannot be a member of a political party.

“I promise to continue to work with the new administration in the leadership of our new co-chairs to do all I can to fix all of our shortcomings, deficiencies and mistakes,” he said in a letter to the congress.