SKOPJE, Macedonia — A court in Macedonia has convicted 33 people of being members of an ethnic Albanian militant group and planning terrorist attacks.

The suspects were arrested following a deadly police raid in 2015. The raid and an ensuing gun battle near in the northern border town of Kumanovo left eight officers and 10 militants dead.

Seven of the defendants were handed life sentences on Thursday, and another 13 were sentenced to 40 years in prison. Others got prison sentences from 12 to 20 years. Four men were cleared.

The trial, which lasted 20 months, was held under heavy security and the defendants were brought to the court Thursday by helicopter. State prosecutors had sought life sentences for all 37 on trial.

According to a 40-page indictment, the militants had crossed into the country from neighboring Kosovo and planned attacks on government sites in northern Macedonia. It said they had stolen weapons from an army border post, and opened fire on police while officers were carrying out searches.

The militants used assault rifles, rocket-propelled grenades, and hand grenades in a densely built-up neighborhood. At least ten houses were destroyed in the fighting.

Court officials said some defendants were from Kosovo and others were ethnic Albanians from Macedonia.

Macedonia has a large ethnic Albanian minority and fought a nine-month insurgency against militants from the minority in 2001.

The defendants all denied the charges and their lawyers said they would appeal.

“We didn’t expect fair sentences, but we also didn’t expect such a draconian ruling. It was a classic show trial,” Naser Raufi, one of the lawyers for the defense said.