BUCHAREST, Romania (AP) — Romania's most powerful politician was convicted Thursday of official misconduct and sentenced to 3 ½ years in prison, a verdict cautiously cheered by anti-government protesters who have spent months decrying high-level corruption in the European country.

After hours of deliberation, the High Court of Cassation and Justice found Social Democratic Party leader Liviu Dragnea guilty of intervening to keep two party members on the payroll of a public family welfare agency. Dragnea, who denied wrongdoing, can appeal.

As leader of Romania's ruling party leader, Dragnea normally would be the country's prime minister. A 2016 conviction for vote-rigging barred him from the post.

Dragnea selected ally Viorica Dancila to be prime minister in January. Dancila criticized the court ruling and said fellow politicians calling for Dragnea to step down as parliament speaker — the third most senior position in government — were acting "unconstitutionally."

After the ruling was handed down, thousands of Romanians gathered in Bucharest and other cities to oppose criminal justice changes lawmakers made this week. Critics think the changes will make it harder to prosecute and punish officials for corruption.

"It's a small victory," said Maria Belizarie, a legal consultant who was among the flag-waving crowd in Victory Square. "I respect the magistrates who today respected the robes they wear and the oath they took."

Prosecutors said Dragnea intervened from 2008 to 2010, when he was a government official, to keep two women employed by his party on the payroll of the family welfare agency. The women admitted working for the party while they received salaries from the public agency.

The Social Democrats will meet Friday to discuss the party's future following its leader's conviction.