DRESDEN - A German man who used a homemade bomb to attack a mosque in the eastern city of Dresden was Friday sentenced to nearly 10 years in jail for what prosecutors called a xenophobic crime.

The accused, Nino Koehler, had apologised during his trial to the imam and his family. No one was hurt in the attack. The bomb damaged the door of the Fatih mosque while the family were inside on September 26, 2016.

That same evening, the accused planted another homemade pipe bomb that slightly damaged a convention centre in the city, which was days away from hosting festivities to mark 26 years since the reunification of east and west Germany.

The attacks in Dresden, the capital of Saxony state and the birthplace of the anti-Islam PEGIDA movement, shocked Germany. The city's district court found Koehler guilty of attempted murder, setting off explosives and attempted aggravated arson.

The judge sentenced him to nine years and eight months in jail.

Prosecutors him during the trial of harbouring racist and Islamophobic motives, and media reports said he had railed against "lazy Africans" and "criminal foreigners" at a past PEGIDA rally.

Koehler, who was arrested in December 2016, told the judge that he never meant to hurt anyone.

Saxony, in Germany's ex-communist east, has become a hotspot for far-right protests and hate crimes after more than a million asylum seekers arrived in Europe's biggest economy since 2015.

The Saxony town of Chemnitz has been rocked by racist violence this week, after far-right mobs took to the streets to protest the fatal stabbing of a German man, allegedly by an Iraqi and a Syrian.