(CNN) -- A German man was convicted Wednesday of murder and sentenced to life in prison for the fatal stabbing of an Egyptian woman, a Dresden, Germany, a court spokesman said.
Peter Kiess said the court found that the man -- a 29-year-old, unemployed, ethnic Russian identified only as Alex W.-- stabbed Marwa El-Sherbini during a defamation hearing in July.
The court determined that one of his motives was hatred of foreigners, Kiess said.
Kiess said the earliest Alex W. could ask for a parole hearing would be after 18 to 19 years in prison because of the severity of the crime.
The court also convicted him of attempted murder for stabbing Sherbini's husband, who had rushed to her aid in the courtroom in Dresden, Kiess said.
The court spokesman said the defendant hid his face under a hooded sweater and sunglasses while the verdict was read.
Sherbini, who had moved to Dresden in 2003, had sued Alex W. for insult and abuse for an incident last year, accusing him of calling her a "terrorist" and "Islamist."
A court found him guilty of defamation and fined him 780 euros ($1,172), and Alex W. appealed the ruling.
The two sides appeared in court again on July 1, and after Sherbini finished testifying, Alex W. pulled out a knife from his backpack and attacked her. He also allegedly stabbed her husband three times and attacked another person.
According to media reports, police officers tried to intervene to end the fight, and a number of shots were fired. One hit the husband, sending him to a hospital where he lay in a coma for two days.
The killing of Sherbini, a pharmacist who was three months pregnant, stirred outrage in the Muslim world, especially in her native Egypt. Many accused Germany of lax security and for not adequately protecting its minority Muslim population from a new wave of hatred against Arabs.
Anger in the Arab world was fanned by what was seen as the muted German reaction soon after the incident. The country's media reported on the murder but did not touch upon the racist aspect of the killing, and Egyptians deemed the response as a sign of Islamophobia.
Hundreds attended Sherbini's funeral in her hometown of Alexandria, Egypt, and Muslims also angrily protested in Berlin, Germany.
Police cordoned off streets around the court during the proceedings, and about 200 officers stood guard.
"We welcome this sentence as the harshest possible sentence under German law," said Husam Zaki, a spokesman for the Egyptian Foreign Ministry.
"We hope that this sentence will serve as a lesson for all those who are motivated by hate."
Also in Egypt, Issam Al-Aryan, the Muslim Brotherhood leader, said he was very happy with the sentence. "It is fair and reassures Arabs and Muslims that they can live in comfort and safety in Western society."
Sherbini moved to Dresden in 2003 after her husband received a grant to study genetic engineering in the Max Planck Institute. He was scheduled to present his doctoral thesis when his wife was killed.
CNN's Ben Wedeman contributed to this report.