A Greek court has released 26 anarchists who had disrupted a Sunday Orthodox church service to protest against refugee evictions, a judicial source said.

After landing in Greece, refugees struggle with loss

The activists ran into the Thessaloniki cathedral on Sunday, scattering leaflets that read "Solidarity with the refugees", before they were arrested by anti-riot forces.

Among those arrested were nine foreigners from Austria, Britain, Germany, Morocco, Spain and Switzerland.

The Thessaloniki court threw out charges of "disturbing a religious gathering".

However, 19 of the activists were handed suspended six-month prison sentences for refusing to be fingerprinted by police.

The ruling is suspended over a three-year period.

READ MORE: Greek anarchists organise for refugees as 'state fails'

The protest came after city authorities last week forced refugees out of three buildings where they had been squatting, including an orphanage belonging to the diocese.

An incendiary device was also set off earlier on Sunday outside the company that demolished the orphanage. Nobody was hurt.

A number of abandoned buildings in Athens and Thessaloniki in recent months have been taken over by anarchists and groups providing refugees and migrants with housing amid concerns about the poor humanitarian conditions in Greek camps. 

Official estimates say more than 2,000 refugees are currently living in such squats, mostly former schools.

While the Greece's Syriza government has been quietly tolerant of the squatters, local authorities have taken a harsher stance, claiming there are concerns of health and safety hazards.

Greek authorities have been criticised for the poor conditions in the camps.  

READ MORE: Greek anarchists cook in solidarity for refugees

Ever since Balkan nations on the refugee trail closed their borders earlier this year, the Greek government has been struggling to cope with a build-up of new arrivals prevented from continuing their journey further north into Europe.

Greece is currently hosting about 57,000 people, among them Syrians, Iraqis, Afghans and people from across the Middle East and Africa. 

Fleeing war and economic devastation, more than a million refugees and migrants reached Europe by boat in 2015, according to the United Nations refugee agency. Upwards of 256,000 have made the journey so far this year. 

Inside Story - Who's to blame for the worsening refugee crisis?

Source: Al Jazeera and agencies