The founder of Germany’s xenophobic and anti-Islam Pegida movement has appeared in court on hate speech charges for allegedly branding refugees “cattle” and “scum” on social media.

Lutz Bachmann, founder of the far-right Patriotic Europeans against the Islamisation of the Occident movement, was charged in October with inciting racial hatred through a series of widely shared Facebook posts.

The trial was held on Tuesday under tight security in Dresden in the former communist east, the birthplace of Pegida, which bitterly opposes Angela Merkel’s liberal migration policy, which brought more than a million asylum seekers to Germany last year.

The court said Bachmann’s comments, which date back to September 2014, constituted an “attack on the dignity” of refugees.

If found guilty, the 43-year-old could face between three months and five years in jail.

Lutz Bachmann has railed against ‘traitor’ politicians and the ‘liar press’. Photograph: Jens Meyer/EPA

Bachmann, who has branded the process a “political show trial”, appeared in court smiling, wearing glasses that mimicked the black bars printed over people’s eyes in censored photos. He did not speak in court.

Outside, several dozen supporters cheered Bachmann and waved signs that called for Merkel to be put on trial, as counter-demonstrators chanted “Jail for Bachmann”.

His defence lawyer, Katja Reichel, said Bachmann had not written the offending words and that his Facebook account may have been hacked.

However, the court also watched video footage of a Pegida rally in January 2015 in which Bachmann appeared to be defending the Facebook comments, saying he had merely “used words that everyone has used at least once”.

Pegida rallies at that time peaked at around 25,000 people, but interest then began to wane following wide coverage of Bachmann’s overtly racist comments and the surfacing of selfies in which he sported a Hitler-style moustache and hairstyle.

A few months later the pendulum swung back as tens of thousands of asylum seekers – many fleeing war in mostly Muslim countries such as Syria, Iraq and Afghanistan – poured into Germany each week.

Bachmann has repeatedly labelled the new arrivals “criminal invaders” while also blaming “traitor” politicians and the “liar press” for jointly promoting multiculturalism.

At Pegida’s weekly rally in Dresden on Monday, Bachmann made no reference to his trial but waded into a row over a German comedian who wrote a satirical poem about the Turkish president, Recep Tayyip Erdoğan.

Popular comic Jan Böhmermann could be convicted under a rarely enforced section of the criminal code – insulting organs or representatives of foreign states.

“Imagine the outcry... if that poem had been written by me,” Bachmann told a crowd of several thousand. “I would have been immediately arrested on stage, placed in custody... [and] executed,” he said.

A trained chef and head of a public relations agency, Bachmann has previously been convicted of drug, theft and assault charges. In the late 1990s, he left Germany for South Africa to avoid a jail term, but was extradited two years later and served 14 months behind bars in Germany.

The eastern state of Saxony, of which Dresden is the capital, has been a hotspot for many of the 800 attacks on refugee shelters recorded in Germany last year.

Small towns such as Freital near Dresden earned nationwide notoriety last year as neo-Nazis and angry residents hurled abuse at people fleeing war and misery – and rocks at police sent to protect those seeking a safe haven.

An elite German police anti-terrorism unit carried out dawn raids on Tuesday to capture five rightwing extremist suspects accused of attacking refugee shelters and political opponents, federal prosecutors said.

The suspects, four men and a woman, are accused of belonging to a far-right terrorist organisation called the Freital Group.

“According to preliminary investigations, the aim of the group was to carry out explosives attacks on homes for asylum seekers as well as the homes of political opponents,” the prosecutor’s office said in a statement.

It said the suspects stockpiled hundreds of fireworks from the Czech Republic to use in attacks. The assaults include blowing out the windows of the kitchen of a refugee shelter in Freital in September 2015.