The defendant, who entered the Düsseldorf courtroom hiding his face under a blue jacket, allegedly groped a woman while he and some 15 to 20 other men encircled and also assaulted her.
The 18-year-old woman told the court of her panic as the man lifted her skirt to touch her buttocks while feeling countless other hands touching her breasts and genital area in a terrifying mob attack.
She said she later identified the defendant from unrelated television footage screened in a "Spiegel TV" news reportage on pickpockets in the city of Düsseldorf.
Germany was appalled by the wave of sexual assaults and other crimes targeting women on New Year's Eve, mainly in Cologne but also in several other cities including Düsseldorf, where police received 118 criminal complaints.
The Cologne attacks in particular - reportedly committed by men who appeared to be of Middle Eastern or north African origin - heightened public fears about a mass influx of refugees and migrants.
Right-wing populist groups protested against "rape-fugees" and "sex-jihadists" while condemning the arrival of more than one million asylum seekers last year, the majority from war-torn Syria, Iraq and Afghanistan.
The court heard that the Moroccan man accused of attacking the woman in Düsseldorf also faces separate unspecified assault and property damage charges, and has four previous theft convictions.
Prosecutor Laura De Bruyn said that "the accused and his accomplices encircled and trapped the young woman and repeatedly touched her breasts, her buttocks but also her genital area".
The man had entered Germany in April 2014 when he filed a request for political asylum which was later rejected, but continued to stay in a shelter for asylum seekers, she said.
"The injured party has said that she was watching a television report in which the defendant gave an interview about a different matter," said De Bruyn.
"She clearly recognized him as the perpetrator and decided to file charges."
Correction: The headline of this story previously incorrectly stated that the man went on trial for a crime in Cologne. In fact, it happened in Düsseldorf. The Local regrets the error.