The 12-year-old, originally from Morocco, is going to school in Frankfurt. She had refused to take part in swimming lessons and had been marked down.
She filed to be given the right to skip the classes, her lawyer arguing that according to the Koran, she was not only forbidden from showing herself to boys but also from seeing boys topless.
An administrative court in Kassel, near Frankfurt, rejected her application.
It said in its ruling that she could wear the full-body swimsuit, known as the “burkini” already used by several girls at her school, which would be enough to guarantee her religious freedom.
The court added that the family had chosen to live in Germany where mixed swimming classes were the norm.
One of the aims of the school system was to promote integration and tolerance, the court added, citing a ruling by Germany’s constitutional court.
The applicant would have to put up with the sight of her classmates in their swimming costumes, the court said.